From b3fc191b589a5766e063c7dd365c217cdc34aefc Mon Sep 17 00:00:00 2001 From: Kimmo Pekkola Date: Mon, 27 Jul 2009 11:52:07 +0000 Subject: [PATCH] ASysInfo plugin can show Vista and Win7 in OS_VERSION. Added OS_BITS to the SysInfo plugin. --- Plugins/PluginSysInfo/SysInfo.cpp | 56 ++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/Plugins/PluginSysInfo/SysInfo.cpp b/Plugins/PluginSysInfo/SysInfo.cpp index b24b0962..67f5f8e8 100644 --- a/Plugins/PluginSysInfo/SysInfo.cpp +++ b/Plugins/PluginSysInfo/SysInfo.cpp @@ -50,6 +50,7 @@ MULTIMONITOR_INFO m_Monitors = { 0 }; BOOL CheckConnection(); void GetOSVersion(WCHAR* buffer); +void GetOSBits(WCHAR* buffer); BOOL CALLBACK MyInfoEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); enum TYPE @@ -60,6 +61,7 @@ enum TYPE SCREEN_SIZE, RAS_STATUS, OS_VERSION, + OS_BITS, ADAPTER_DESCRIPTION, NET_MASK, IP_ADDRESS, @@ -126,6 +128,10 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id) { g_Types[id] = OS_VERSION; } + else if (wcsicmp(L"OS_BITS", type) == 0) + { + g_Types[id] = OS_BITS; + } else if (wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0) { g_Types[id] = ADAPTER_DESCRIPTION; @@ -279,6 +285,10 @@ LPCTSTR GetString(UINT id, UINT flags) GetOSVersion(buffer); return buffer; + case OS_BITS: + GetOSBits(buffer); + return buffer; + case ADAPTER_DESCRIPTION: if (ERROR_SUCCESS == GetAdaptersInfo((IP_ADAPTER_INFO*)buffer, &len)) { @@ -521,9 +531,9 @@ void Finalize(HMODULE instance, UINT id) */ void GetOSVersion(WCHAR* buffer) { - OSVERSIONINFO version; - version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&version); + OSVERSIONINFOEX version; + version.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + GetVersionEx((OSVERSIONINFO*)&version); if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) { @@ -531,7 +541,7 @@ void GetOSVersion(WCHAR* buffer) { wcscpy(buffer, L"Windows NT"); } - else + else if (version.dwMajorVersion == 5) { if (version.dwMinorVersion == 2) { @@ -550,6 +560,29 @@ void GetOSVersion(WCHAR* buffer) wcscpy(buffer, L"Unknown"); } } + else + { + if (version.dwMinorVersion == 1 && version.wProductType == VER_NT_WORKSTATION) + { + wcscpy(buffer, L"Windows 7"); + } + else if (version.dwMinorVersion == 1 && version.wProductType != VER_NT_WORKSTATION) + { + wcscpy(buffer, L"Windows Server 2008 R2"); + } + else if (version.dwMinorVersion == 0 && version.wProductType == VER_NT_WORKSTATION) + { + wcscpy(buffer, L"Windows Vista"); + } + else if (version.dwMinorVersion == 0 && version.wProductType != VER_NT_WORKSTATION) + { + wcscpy(buffer, L"Windows Server 2008"); + } + else + { + wcscpy(buffer, L"Unknown"); + } + } } else { @@ -568,6 +601,21 @@ void GetOSVersion(WCHAR* buffer) } } +void GetOSBits(WCHAR* buffer) +{ + SYSTEM_INFO systemInfo = {0}; + GetNativeSystemInfo(&systemInfo); + + if (systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 || + systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) + { + wcscpy(buffer, L"64"); + } + else + { + wcscpy(buffer, L"32"); + } +} /* Tests if there is a RAS connection or not. Don't know