Index: cfgmgr/cfgmgr.cpp |
— | — | @@ -304,6 +304,56 @@ |
305 | 305 | RegCreateKeyEx(HKEY_CURRENT_USER,regkey.c_str(),0,NULL,0,KEY_ALL_ACCESS,NULL,&hKey,NULL);
|
306 | 306 | ReadSettings(hKey,cfg,NULL,false,true,NULL);
|
307 | 307 | RegCloseKey(hKey);
|
| 308 | + hKey = NULL;
|
| 309 | + HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
|
| 310 | + BOOL (WINAPI *iswow64)(HANDLE,PBOOL) = NULL;
|
| 311 | + iswow64 = (BOOL(WINAPI*)(HANDLE,PBOOL))GetProcAddress(hKernel32,"IsWow64Process");
|
| 312 | + BOOL is64 = FALSE;
|
| 313 | + if(iswow64) iswow64(GetCurrentProcess(),&is64);
|
| 314 | + FreeLibrary(hKernel32);
|
| 315 | + LRESULT error;
|
| 316 | + if(is64) error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ|KEY_WOW64_64KEY,&hKey);
|
| 317 | + else error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ,&hKey);
|
| 318 | + if(error == ERROR_SUCCESS)
|
| 319 | + {
|
| 320 | + GetModuleFileName(NULL,filename,MAX_PATH);
|
| 321 | + TCHAR buffer[1024];
|
| 322 | + ZeroMemory(buffer,1024*sizeof(TCHAR));
|
| 323 | + DWORD sizeout = 1024*sizeof(TCHAR);
|
| 324 | + if(RegQueryValueEx(hKey,filename,NULL,NULL,(LPBYTE)buffer,&sizeout) == ERROR_SUCCESS)
|
| 325 | + {
|
| 326 | + if(_tcsstr(buffer,_T("DWM8And16BitMitigation")))
|
| 327 | + {
|
| 328 | + MessageBox(NULL,_T("DXGL has detected an incompatible AppCompat flag for the program you are currently running. To continue, the registry value must be deleted.\nIf you see a UAC prompt, you must click Yes."),
|
| 329 | + _T("AppCompat error"),MB_OK|MB_ICONHAND);
|
| 330 | + error = RegDeleteValue(hKey,filename);
|
| 331 | + if(error == ERROR_ACCESS_DENIED)
|
| 332 | + {
|
| 333 | + tstring command;
|
| 334 | + if(is64) command.assign(_T("DELETE \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /reg:64 /f /v "));
|
| 335 | + else command.assign(_T("DELETE \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v "));
|
| 336 | + command.append(filename);
|
| 337 | + SHELLEXECUTEINFO info;
|
| 338 | + ZeroMemory(&info,sizeof(SHELLEXECUTEINFO));
|
| 339 | + info.cbSize = sizeof(SHELLEXECUTEINFO);
|
| 340 | + info.lpVerb = _T("runas");
|
| 341 | + info.lpFile = _T("reg.exe");
|
| 342 | + info.lpParameters = command.c_str();
|
| 343 | + info.nShow = SW_SHOWNORMAL;
|
| 344 | + info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| 345 | + ShellExecuteEx(&info);
|
| 346 | + WaitForSingleObject(info.hProcess,INFINITE);
|
| 347 | + GetExitCodeProcess(info.hProcess,(LPDWORD)&error);
|
| 348 | + }
|
| 349 | + if(!error)
|
| 350 | + {
|
| 351 | + MessageBox(NULL,_T("Registry value successfully deleted. Please restart the program."),_T("Success"),MB_OK|MB_ICONINFORMATION);
|
| 352 | + exit(0);
|
| 353 | + }
|
| 354 | + else MessageBox(NULL,_T("Registry value could not be deleted. Your program may crash as a result."),_T("Error"),MB_OK|MB_ICONWARNING);
|
| 355 | + }
|
| 356 | + }
|
| 357 | + }
|
308 | 358 | }
|
309 | 359 | void GetGlobalConfig(DXGLCFG *cfg)
|
310 | 360 | {
|
Index: cfgmgr/stdafx.h |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | #include <stdlib.h>
|
25 | 25 | #include <cstdio>
|
26 | 26 | #include <Windows.h>
|
| 27 | +#include <ShellAPI.h>
|
27 | 28 | #include <string>
|
28 | 29 | #ifndef LSTATUS
|
29 | 30 | typedef LONG LSTATUS;
|