Getting Windows Version
#pragma comment(lib, "netapi32.lib")
#include <LM.h>
BOOL GetWindowsVersion(DWORD &dwMajorVersion, DWORD &dwMinorVersion) {
LPWKSTA_INFO_100 pBuf = NULL;
if (NetWkstaGetInfo(NULL, 100, (LPBYTE *)&pBuf) != NERR_Success)
return FALSE;
// Check if NT platform
if (pBuf->wki100_platform_id != PLATFORM_ID_NT)
return FALSE;
dwMajorVersion = pBuf->wki100_ver_major;
dwMinorVersion = pBuf->wki100_ver_minor;
NetApiBufferFree(pBuf);
return TRUE;
}
Getting Windows Platform
void CheckWindowsPlatform() {
#ifdef _WIN32
#ifdef _WIN64
#ifdef _M_X64
_tprintf(_T("Windows x64\n"));
#elif defined _M_IA64
_tprintf(_T("Windows IA64\n"));
#endif
#elif defined _M_IX86
BOOL bWow64Process = FALSE;
IsWow64Process(GetCurrentProcess(), &bWow64Process);
if (bWow64Process)
_tprintf(_T("Windows x64\n"));
else
_tprintf(_T("Windows x86\n"));
#endif
#else
#error Not support this architecture
#endif
}
References