Click here to Skip to main content
15,897,518 members
Articles / General Programming / String

Converting TCHAR[] to string, while getting PC Name

Rate me:
Please Sign up or sign in to vote.
3.67/5 (3 votes)
17 May 2010CPOL2 min read 18.5K   2  
Hi there,Its been a while since I wrote my last article. Since got myself into a problem of getting the system name of my PC.I dragged my C instincts into the MSDN world of asking how to get the PC name.After fiddling for a while I got hold of the PC name, not that difficult as a...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
8 Jun 2010Alain Rist
You might have considered using ::GetComputerNameA() which does the conversion for you:std::string GetSystemName(){ CHAR sBuf[MAX_COMPUTERNAME_LENGTH + 1] = {0}; DWORD dwLen = MAX_COMPUTERNAME_LENGTH; ::GetComputerNameA(sBuf, &dwLen); return std::string(sBuf);}Note...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer -
Pakistan Pakistan
Computer Programming

Comments and Discussions