Sign in to follow this  

GetComputerName( ) question

This topic is 4691 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
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

This topic is 4691 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this