Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

GetComputerName return is too short for my computer name... what to do?

Writer Andrew Mclaughlin

My computer name is similar to this: "ABC12-PEACEBRINGER" (18 characters) and it's a windows xp machine although the final program also needs to run on windows 7.

When I use the following c++ code the computer name gets cut off and the return isABC12-PEACEBRIN.

TCHAR MachineName[32];
DWORD buf = 32;
GetComputerNameA(MachineName, &buf);

Btw. when I type ipconfig /all into my cmd I do get the complete computer name.

I tried some different solutions from the msdn homepage but the result remains the same.

Does anyone know a solution to get a computer name of that length?! ...Changing the name is not a solution ;-)

1

1 Answer

NetBIOS names (which GetComputerName returns) are limited to 15 characters.

You likely want some other variation -- look at GetComputerNameEx to see your options.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.