Hello,
Is there any function what retrieves name of computer the application is running on?
Thanks
Printable View
Hello,
Is there any function what retrieves name of computer the application is running on?
Thanks
Lookup the man page on uname.
int gethostname(char *name, int namelen);
Strait out of MSDN! Hes not running on Windows, and therefore does not have Winsock.Quote:
The Windows Sockets gethostname function returns the standard host name for the local machine.
gethostname() is available on many systems, not just Windows.Quote:
Originally posted by mwilliamson
Strait out of MSDN! Hes not running on Windows, and therefore does not have Winsock.
It's available on many unix systems:
http://www.mcsr.olemiss.edu/cgi-bin/...?gethostname+2
Okay, thank you gentlemen (or gentlewomen) :)
I got it. I did not want to link sockets stuff on Solaris (as I do not link winsock for GetComputerName, just MFC).
Is there a chance to get the computer name w/o the socket stuff?
uname will not work on old unix systems ,there for gethostname will be the best solution
uname will work from Solaris 2.6 onwards. Don't know about 2.5. On 2.6, because gethostname was a BSD thing, you will need to declare it explicitly as it is not included in any header file. Well, that's my penny's worth - things may have changed on later versions of Solaris: I think it is now on 2.9.