Jump to content
  • Advertisement
Sign in to follow this  
i1977

GetComputerName( ) question

This topic is 4998 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to get the computer name for use in a tool I'm working on. When I use the GetComputerName() function, I do get my computer's name, but it's written in capital letters. However, if I do Ctrl-Break in Windows and look at the computer name written there, it's written in lowercase letters. The third party library I'm using is case sensitive and has problems operating if I pass it the capitalized computer name I get for the Win32 API call above. Is there another way to get the computer name that would be more accurate? (I know I could de-capitalize the string myself in my code, but then computers that do have a name with capital letters will start failing, so this is not an option) Thanks for any advice!

Share this post


Link to post
Share on other sites
Advertisement
The function retrieves the NetBIOS name of the computer, that is a 15-chars uppercase string. So no matter what you read in windows, your name is actually internally stored as uppercase.

Share this post


Link to post
Share on other sites
Try reading it directly from the registry at:
HKLM\System\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName
or
HKLM\System\CurrentControlSet\Services\Tcpip\Parameters\Hostname
(The latter being mixed case)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!