[Snippet] Detecting Operating System. [Also C++ Lessons?]
Had a bit of trouble finding this out for myself simply because Ive never done it before. But MSDN was more than helpful. This is my easier to understand version I guess and I hope it helps some of y'all out. As you know it was on one of my injectors and I got a few PMs asking how I did it so here it is.
Code:
//Operating System Detection
OSVERSIONINFO OS;
ZeroMemory(&OS, sizeof(OSVERSIONINFO));
OS.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&OS);
if (OS.dwMajorVersion == 6 && OS.dwMinorVersion == 1) {
Log->Lines->Add(”Windows 7 Detected”);
}
if (OS.dwMajorVersion == 6 && OS.dwMinorVersion == 0) {
Log->Lines->Add(”Windows Vista Detected”);
}
if (OS.dwMajorVersion == 5) {
Log->Lines->Add(”Windows XP Detected”);
}
Also, if you wanted to get the name of the current user logged on:
//Get Computer Information
Code:
TCHAR sUserName[UNLEN + 1];
TCHAR sCompName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD dwUserName = sizeof(sUserName);
DWORD dwCompName = sizeof(sCompName);
GetUserName(sUserName, &dwUserName);
GetComputerName(sCompName, &dwCompName);
How many of you guys would be interested in starting a set of classes geared towards teaching the average users the basics of C++? I was thinking bout hosting sessions