From fe6ea623637a94f74ce60cbf134783bfcbdf5e0b Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Thu, 10 Sep 2015 01:32:55 +0200 Subject: Windows: Don't offer creating a restore point if it is disabled in Windows. --- src/Setup/Setup.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c index bd7a6ee4..d93b4ced 100644 --- a/src/Setup/Setup.c +++ b/src/Setup/Setup.c @@ -490,6 +490,39 @@ HRESULT CreateLink (char *lpszPathObj, char *lpszArguments, return hres; } +BOOL IsSystemRestoreEnabled () +{ + BOOL bEnabled = FALSE; + HKEY hKey; + DWORD dwValue = 0, cbValue = sizeof (DWORD); + if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore", 0, KEY_READ | KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS) + { + if (IsOSAtLeast (WIN_VISTA)) + { + if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, "RPSessionInterval", NULL, NULL, (LPBYTE) &dwValue, &cbValue)) + && (dwValue == 1) + ) + { + bEnabled = TRUE; + } + } + else + { + if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, "DisableSR", NULL, NULL, (LPBYTE) &dwValue, &cbValue)) + && (dwValue == 0) + ) + { + bEnabled = TRUE; + } + } + + + RegCloseKey (hKey); + } + + return bEnabled; +} + void GetProgramPath (HWND hwndDlg, char *path) { ITEMIDLIST *i; @@ -2554,14 +2587,19 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm } // System Restore - char dllPath[MAX_PATH]; - if (GetSystemDirectory (dllPath, MAX_PATH)) + if (IsSystemRestoreEnabled ()) { - StringCbCatA(dllPath, sizeof(dllPath), "\\srclient.dll"); + char dllPath[MAX_PATH]; + if (GetSystemDirectory (dllPath, MAX_PATH)) + { + StringCbCatA(dllPath, sizeof(dllPath), "\\srclient.dll"); + } + else + StringCbCopyA(dllPath, sizeof(dllPath), "C:\\Windows\\System32\\srclient.dll"); + SystemRestoreDll = LoadLibrary (dllPath); } else - StringCbCopyA(dllPath, sizeof(dllPath), "C:\\Windows\\System32\\srclient.dll"); - SystemRestoreDll = LoadLibrary (dllPath); + SystemRestoreDll = 0; if (!bUninstall) { -- cgit v1.2.3