GetComputerName return is too short for my computer name... what to do?
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 ;-)
11 Answer
NetBIOS names (which GetComputerName returns) are limited to 15 characters.
You likely want some other variation -- look at GetComputerNameEx to see your options.