Thanks for your reply. However, I am looking for something that returns me
the physical address and not the IP address.
This function is kind of MFC-centric, but it may work for you:
#include <winsock.h>
#include <winnetwk.h>
//
// Returns the host name and IP address
//
CString GetHostName(CString &csIPAddress)
{
CString compName;
_TCHAR buff[MAX_COMPUTERNAME_LENGTH + 1];
DWORD count = MAX_COMPUTERNAME_LENGTH + 1;
compName.Empty();
if (::GetComputerName(buff, &count)) {
compName = buff;
WORD wVersionRequested;
WSADATA wsaData;
char name[255];
PHOSTENT hostinfo;
wVersionRequested = MAKEWORD( 1, 0 );
if(WSAStartup(wVersionRequested, &wsaData) == 0) {
if(gethostname(name, sizeof(name)) == 0) {
if((hostinfo = gethostbyname(name)) != NULL)
csIPAddress = inet_ntoa (*(struct in_addr
*)*hostinfo->h_addr_list);
}
WSACleanup( );
}
}
return compName;
}
Tom
"cleohm" <cleohm@discussions.microsoft.com> wrote in message
news:243486C2-D294-4404-8560-CE7B89E34F76@microsoft.com...
Hi,
Does anyone know of a way to get the host id of a machine using VS C++?
Regards
cleohm