Game Development Community

getcomputername engine console function

by Helmetron · in Torque Developer Network · 11/09/2010 (6:43 pm) · 2 replies

#include <windows.h>
#include <stdio.h>

ConsoleFunction( GetComputerName, const char*, 1, 1, "Get the Computer Name from this machine" ){

TCHAR chrComputerName[64];
DWORD dwBufferSize = 64;
char* ret = Con::getReturnBuffer(64);


if(GetComputerName((LPWSTR)chrComputerName,&dwBufferSize)) {
wcstombs(ret, chrComputerName,64);
return ret;
} else {
ret = "";
}

return(ret);
}

#1
11/10/2010 (4:02 am)
Nifty! Would be best to post this in the Resources section.
#2
11/10/2010 (1:42 pm)
I tried posting to resource but it was not long enough to qualify. They have a minimum character requirement.