Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IP address from VFP
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00141462
Message ID:
00141576
Views:
116
>>>>I came across this little snippet while surfing the net and thought some might find it useful. It give the user ip address.
>>>>
>>>>
>>>>* Show local ip address
>>>>IPSocket = CreateObject("MSWinsock.Winsock")
>>>>IPAddress = IPSocket.LocalIP
>>>>MessageBox ("Local IP = " + IPAddress)
>>>>
>>>
>>>Hi John,
>>>
>>>Oh, that's sweet and easy.:-) The object that's returned has some other useful properties too, such the host name.
>>
>>Yeah, I found it while trying to do Windows Scripting Host. I havent' been able to create the WSH object. I don't suppose you would have a handle on how that's done?
>
>Hi John,
>
>Nope I don't. Sorry. If I run into anything, however, I'll keep you in mind.
>
>A couple of notes on the Winsock thing. For this to work, you'll have to have the MSWinsock ActiveX control installed. If you do, you can simply drop one of these on a form, and access the help file through there.


Yeah, I thought I'd post the following on the FAQ section (at the recommendation of John Koziol.)

* getipaddress.prg
* John Harvey
* 9/28/98
* Leave IPSocket public to view all properties in the debug window.
* I stumbled on this routine while trying to find information on subclassing
* the WSH and thought it might be useful.
public IPSocket
crlf=chr(13)+chr(10)
* Show local ip address
IPSocket = CreateObject("MSWinsock.Winsock")
if type('IPSocket')='O'
IPAddress = IPSocket.LocalIP
localhostname=IPSocket.localhostname
remotehost=IPSocket.remotehost
remotehostip=IPSocket.remotehostip
MessageBox ("Local IP = " + IPAddress+crlf+"local host = "+localhostname;
+crlf+"Remotehost = "+remotehost+crlf+"Remotehostip = "+remotehostip)
else
MessageBox ("Winsock Is Not Installed!")
endif
John Harvey
Shelbynet.com

"I'm addicted to placebos. I could quit, but it wouldn't matter." Stephen Wright
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform