Hi,
Is there another way other than API gethostname to get server name for local machine?
I have to link wsock32.lib in order to use that API. Then, my app will become more fat.
Thank you.
Printable View
Hi,
Is there another way other than API gethostname to get server name for local machine?
I have to link wsock32.lib in order to use that API. Then, my app will become more fat.
Thank you.
you can load wsock32.dll with LoadLibrary() and then call to gethostname with GetProcAddress()
or try getenv( "COMPUTERNAME" );
Use the following code:
TCHAR m_szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD dwNameSize = MAX_COMPUTERNAME_LENGTH + 1;
::GetComputerName (m_szComputerName, &dwNameSize);
Works every time
Yes, I use this API getComputerName(). Thank you.