Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winsock questions: IP returning or registry reading 2

Status
Not open for further replies.

vlitzer

Programmer
Joined
Apr 30, 2002
Messages
31
Location
AR
Im working in a crude server/client architecture. So i want to know if is there a function that returns the self IP?. Ive read some articles that i can acces the w registry, and read from there, but i dont know how to read it. Anyone know?
 
The current IP address will be in either this registry value for a fixed IP address:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\<Adapter GUID here>\IPAddress

or here for DHCP addresses:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\<Adapter GUID here>\DhcpIPAddress

The registry is accessed using Win32 API calls. For instance a registry value is read using RegQueryValue(). However there are a few prerequisite steps that need to be taken to read a registry value. I will leave that as an exercise for you, don't worry, it's not that difficult.

Here is a high level pointer into the MSDN documentation that you can drill down into to learn about using the registry functions:


You may have to paste that URL in two passes.
 
wow... thanks so much. The information provided is very usefull to me, thanks a lot!

ejemmm: this is off topic, but... im using mfc's CAsyncSocket... is there a function that returns, if im the server, the cliente IP, after connected?
 
GetPeerName will return the IP and Port of the connected socket.

William
Software Engineer
ICQ No. 56047340
 
thanks again ill try it out!
 
I was not able to find reference to GetPeerName (as suggested by williamu) at allapi.com or in the api viewer. Where can I find it? I need to get the user's ip address from w/in a visual foxpro6 application to be able to pass it to a third party storage application (lexmark/scopeware).

thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top