[MSCONFIG_NEW]: Activate OS-version-specific behaviour (ReactOS vs. Windows and pre-Vista vs. post-Vista).

svn path=/trunk/; revision=70728
This commit is contained in:
Hermès Bélusca-Maïto 2016-02-13 13:11:39 +00:00
parent c6443d2f80
commit 340d1b6e9f
5 changed files with 77 additions and 13 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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 = &params;
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);
}

View file

@ -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)
{

View file

@ -74,6 +74,9 @@ VOID ClipOrCenterWindowToMonitor(HWND hWnd, UINT flags);
////////////////////////////////////////////////////////////////////////////////
BOOL IsWindowsOS(VOID);
BOOL IsPreVistaOSVersion(VOID);
LPWSTR
GetExecutableVendor(IN LPCWSTR lpszFilename);