diff --git a/reactos/base/applications/msconfig_new/msconfig.c b/reactos/base/applications/msconfig_new/msconfig.c index 97562ffe4d3..2dc63f5737b 100644 --- a/reactos/base/applications/msconfig_new/msconfig.c +++ b/reactos/base/applications/msconfig_new/msconfig.c @@ -29,7 +29,7 @@ /* Defaults for ReactOS */ BOOL bIsWindows = FALSE; -BOOL bIsOSVersionLessThanVista = TRUE; +BOOL bIsPreVistaOSVersion = TRUE; /* Language-independent Vendor strings */ const LPCWSTR IDS_REACTOS = L"ReactOS"; @@ -232,7 +232,7 @@ HWND CreatePropSheet(HINSTANCE hInstance, HWND hwndOwner, LPCTSTR lpszTitle) psp[nPages].pfnDlgProc = GeneralPageWndProc; ++nPages; - // if (bIsOSVersionLessThanVista) + // if (bIsPreVistaOSVersion) { /* SYSTEM.INI page */ if (MyFileExists(lpszSystemIni, NULL)) @@ -267,7 +267,7 @@ HWND CreatePropSheet(HINSTANCE hInstance, HWND hwndOwner, LPCTSTR lpszTitle) /* FreeLdr page */ // TODO: Program the interface for Vista: "light" BCD editor... - if (!bIsWindows || (bIsWindows && bIsOSVersionLessThanVista)) + if (!bIsWindows || (bIsWindows && bIsPreVistaOSVersion)) { LPCWSTR lpszLoaderIniFile = NULL; DWORD dwTabNameId = 0; @@ -346,12 +346,12 @@ BOOL Initialize(HINSTANCE hInstance) INITCOMMONCONTROLSEX InitControls; /* Initialize our global version flags */ - bIsWindows = TRUE; /* IsWindowsOS(); */ // TODO: Commented for testing purposes... - bIsOSVersionLessThanVista = TRUE; /* IsOSVersionLessThanVista(); */ // TODO: Commented for testing purposes... + bIsWindows = IsWindowsOS(); + bIsPreVistaOSVersion = IsPreVistaOSVersion(); /* Initialize global strings */ szAppName = LoadResourceString(hInstance, IDS_MSCONFIG); - if (!bIsOSVersionLessThanVista) + if (!bIsPreVistaOSVersion) lpszVistaAppName = LoadResourceString(hInstance, IDS_MSCONFIG_2); /* We use a semaphore in order to have a single-instance application */ @@ -367,7 +367,7 @@ BOOL Initialize(HINSTANCE hInstance) */ if ( (hSingleWnd && IsWindow(hSingleWnd)) || ( (hSingleWnd = FindWindowW(L"#32770", szAppName)) != NULL ) || - (!bIsOSVersionLessThanVista ? ( (hSingleWnd = FindWindowW(L"#32770", lpszVistaAppName)) != NULL ) : FALSE) ) + (!bIsPreVistaOSVersion ? ( (hSingleWnd = FindWindowW(L"#32770", lpszVistaAppName)) != NULL ) : FALSE) ) { /* Found it. Show the window. */ ShowWindow(hSingleWnd, SW_SHOWNORMAL); @@ -377,7 +377,7 @@ BOOL Initialize(HINSTANCE hInstance) /* Quit this instance of MSConfig */ Success = FALSE; } - if (!bIsOSVersionLessThanVista) MemFree(lpszVistaAppName); + if (!bIsPreVistaOSVersion) MemFree(lpszVistaAppName); /* Quit now if we failed */ if (!Success) diff --git a/reactos/base/applications/msconfig_new/msconfig.h b/reactos/base/applications/msconfig_new/msconfig.h index 5aad207e648..a391367a287 100644 --- a/reactos/base/applications/msconfig_new/msconfig.h +++ b/reactos/base/applications/msconfig_new/msconfig.h @@ -5,7 +5,7 @@ extern "C" { #endif extern BOOL bIsWindows; -extern BOOL bIsOSVersionLessThanVista; +extern BOOL bIsPreVistaOSVersion; extern const LPCWSTR IDS_REACTOS; extern const LPCWSTR IDS_MICROSOFT; diff --git a/reactos/base/applications/msconfig_new/srvpage.cpp b/reactos/base/applications/msconfig_new/srvpage.cpp index 9649b7241de..1504d109d05 100644 --- a/reactos/base/applications/msconfig_new/srvpage.cpp +++ b/reactos/base/applications/msconfig_new/srvpage.cpp @@ -287,7 +287,7 @@ static void AddService(SC_HANDLE hSCManager, LPENUM_SERVICE_STATUS_PROCESS Servi bAddServiceToList = params.bIsPresent; - if (bIsWindows && bIsOSVersionLessThanVista && !bAddServiceToList) + if (bIsWindows && bIsPreVistaOSVersion && !bAddServiceToList) { QUERY_REGISTRY_VALUES_TABLE ValuesQueryTable[2] = {}; ValuesQueryTable[0].QueryRoutine = GetRegistryValuedDisabledServicesQueryRoutine; @@ -935,7 +935,7 @@ ServicesPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) KeysQueryTable[0].EntryContext = ¶ms; RegQueryRegistryKeys(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", KeysQueryTable, (PVOID)svcName); - if (bIsWindows && bIsOSVersionLessThanVista && !params.bIsPresent) + if (bIsWindows && bIsPreVistaOSVersion && !params.bIsPresent) { QUERY_REGISTRY_VALUES_TABLE ValuesQueryTable[2] = {}; ValuesQueryTable[0].QueryRoutine = GetRegistryValuedDisabledServicesQueryRoutine; @@ -959,7 +959,7 @@ ServicesPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) // // Delete also the valued-entry of the service. // - if (bIsWindows && bIsOSVersionLessThanVista) + if (bIsWindows && bIsPreVistaOSVersion) { HKEY hSubKey = NULL; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", 0, KEY_SET_VALUE /*KEY_READ*/, &hSubKey) == ERROR_SUCCESS) @@ -1022,7 +1022,7 @@ ServicesPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) // // Save also a valued-entry for the service. // - if (bIsWindows && bIsOSVersionLessThanVista) + if (bIsWindows && bIsPreVistaOSVersion) { RegSetDWORDValue(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Shared Tools\\MSConfig\\services", svcName, TRUE, lpServiceConfig->dwStartType); } diff --git a/reactos/base/applications/msconfig_new/utils.c b/reactos/base/applications/msconfig_new/utils.c index 4fabe2942a3..52d5c2dd468 100644 --- a/reactos/base/applications/msconfig_new/utils.c +++ b/reactos/base/applications/msconfig_new/utils.c @@ -221,6 +221,67 @@ VOID ClipOrCenterWindowToMonitor(HWND hWnd, UINT flags) //////////////////////////////////////////////////////////////////////////////// +BOOL IsWindowsOS(VOID) +{ + BOOL bIsWindowsOS = FALSE; + + OSVERSIONINFOW osvi = {0}; + osvi.dwOSVersionInfoSize = sizeof(osvi); + + if (!GetVersionExW(&osvi)) + return FALSE; + + if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) + return FALSE; + + /* ReactOS reports as Windows NT 5.2 */ + + if ( (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion >= 2) || + (osvi.dwMajorVersion > 5) ) + { + HKEY hKey = NULL; + + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + LONG ret; + DWORD dwType = 0, dwBufSize = 0; + + ret = RegQueryValueExW(hKey, L"ProductName", NULL, &dwType, NULL, &dwBufSize); + if (ret == ERROR_SUCCESS && dwType == REG_SZ) + { + LPTSTR lpszProductName = (LPTSTR)MemAlloc(0, dwBufSize); + RegQueryValueExW(hKey, L"ProductName", NULL, &dwType, (LPBYTE)lpszProductName, &dwBufSize); + + bIsWindowsOS = (FindSubStrI(lpszProductName, _T("Windows")) != NULL); + + MemFree(lpszProductName); + } + + RegCloseKey(hKey); + } + } + else + { + bIsWindowsOS = TRUE; + } + + return bIsWindowsOS; +} + +BOOL IsPreVistaOSVersion(VOID) +{ + OSVERSIONINFOW osvi = {0}; + osvi.dwOSVersionInfoSize = sizeof(osvi); + + if (!GetVersionExW(&osvi)) + return FALSE; + + /* Vista+-class OSes are NT >= 6 */ + return ( (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) ? (osvi.dwMajorVersion < 6) : FALSE ); +} + LPWSTR GetExecutableVendor(IN LPCWSTR lpszFilename) { diff --git a/reactos/base/applications/msconfig_new/utils.h b/reactos/base/applications/msconfig_new/utils.h index ab02aed1f37..873cd06d755 100644 --- a/reactos/base/applications/msconfig_new/utils.h +++ b/reactos/base/applications/msconfig_new/utils.h @@ -74,6 +74,9 @@ VOID ClipOrCenterWindowToMonitor(HWND hWnd, UINT flags); //////////////////////////////////////////////////////////////////////////////// +BOOL IsWindowsOS(VOID); +BOOL IsPreVistaOSVersion(VOID); + LPWSTR GetExecutableVendor(IN LPCWSTR lpszFilename);