I am using this code to get the windows version:
#define BUFSIZE 256
bool config::GetOS(LPTSTR OSv)
{
OSVERSIONINFOEX osve;
BOOL bOsVersionInfoEx;
ZeroMemory(&osve, sizeof(OSVERSIONINFOEX));
osve.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osve)) )
return false;
TCHAR buf[BUFSIZE];
StringCchPrintf(buf, BUFSIZE, TEXT("%u.%u.%u.%u"),
osve.dwPlatformId,
osve.dwMajorVersion,
osve.dwMinorVersion,
osve.dwBuildNumber);
StringCchCat(OSv, BUFSIZE, buf);
return true;
}
And I am testing it with:
LPTSTR OSv= new TCHAR[BUFSIZE];
config c;
c.GetOS(OSv);
MessageBox(OSv, 0, 0);
And in the msgbox I get something like this äì5.1.20 (where 5.1.20 is = to OSv) but the first 2 or 3 chars are some weird characters that I don't know when they came from. Even stranger, if I call that second piece again it shows it ok, it only show the weird characters the first time I execute it.
Does someone has an idea what's going on here?