Is there built-in windows C++ function call that can get hostname and IP address? Thanks.
The IP address and hostname of any local computer can be determined using the java. net. InetAddress class.
The gethostbyname function returns a pointer to a hostent structure—a structure allocated by Windows Sockets. The hostent structure contains the results of a successful search for the host specified in the name parameter.
Click the Windows Start button, then "All Programs" and "Accessories." Right-click on "Command Prompt" and choose "Run as Administrator." Type "nslookup %ipaddress%" in the black box that appears on the screen, substituting %ipaddress% with the IP address for which you want to find the hostname.
To get the hostname you can use: gethostname or the async method WSAAsyncGetHostByName
To get the address info, you can use: getaddrinfo or the unicode version GetAddrInfoW
You can get more information about the computer name like the domain by using the Win32 API: GetComputerNameEx.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With