Q: I need the IP address of the local machine. Is there a Windows API function I can use?
Q:
I need the IP address of the local machine. Sys(0) and Id() return the name, but not the IP address. Is there a Windows API function I can use?
A:
If you haven't had to program direct dialogs between two computers connected by TCP/IP, you probably aren't familiar with the Winsock control. Winsock is a standard defined and maintained by Microsoft. It consists of a group of routines that perform communications to and from the IP stack. It allows relatively robust communications across networks that can contain diverse hardware and operating systems. The routines are housed in the Winsock.dll and interfaces with TCP/IP and the Internet.
One of the properties of the Winsock object is LocalIP. It is read-only and will provide a local IP address to VFP with the following two lines of code:
loWinSock = CREATEOBJECT("MSWinsock.Winsock")
?m.loWinSock.LocalIP
By Pamela Thalacker, contributing editor
|
|
|