1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-12-18 10:26:02 +01:00

Used built-in function for checking HKCU and then HKLM

This commit is contained in:
Valentin Radu 2021-09-01 01:17:00 +03:00
parent fff4520ca0
commit 75260bbb32

View File

@ -1102,62 +1102,19 @@ LRESULT CALLBACK OpenStartOnCurentMonitorThreadHook(
MSG* msg = (MSG*)lParam; MSG* msg = (MSG*)lParam;
if (GetSystemMetrics(SM_CMONITORS) >= 2 && msg->message == WM_SYSCOMMAND && (msg->wParam & 0xFFF0) == SC_TASKLIST) if (GetSystemMetrics(SM_CMONITORS) >= 2 && msg->message == WM_SYSCOMMAND && (msg->wParam & 0xFFF0) == SC_TASKLIST)
{ {
BOOL bShouldCheckHKLM = FALSE;
HKEY hKey;
if (RegOpenKeyEx(
HKEY_CURRENT_USER,
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"),
0,
KEY_READ,
&hKey
) != ERROR_SUCCESS)
{
bShouldCheckHKLM = TRUE;
}
DWORD dwStatus = 0; DWORD dwStatus = 0;
DWORD dwSize = sizeof(DWORD); DWORD dwSize = sizeof(DWORD);
if (RegGetValue( HMODULE hModule = GetModuleHandle(TEXT("Shlwapi"));
hKey, FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM");
NULL, LSTATUS x = 0;
TEXT("MonitorOverride"), if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc(
RRF_RT_REG_DWORD,
NULL,
&dwStatus,
(LPDWORD)(&dwSize)
) != ERROR_SUCCESS)
{
bShouldCheckHKLM = TRUE;
}
RegCloseKey(hKey);
if (bShouldCheckHKLM)
{
if (RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"), TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"),
0,
KEY_READ,
&hKey
) != ERROR_SUCCESS)
{
goto finish;
}
dwStatus = 0;
dwSize = sizeof(DWORD);
if (RegGetValue(
hKey,
NULL,
TEXT("MonitorOverride"), TEXT("MonitorOverride"),
RRF_RT_REG_DWORD, SRRF_RT_REG_DWORD,
NULL, NULL,
&dwStatus, &dwStatus,
(LPDWORD)(&dwSize) (LPDWORD)(&dwSize)
) != ERROR_SUCCESS) ) != ERROR_SUCCESS || dwStatus == 1)
{
goto finish;
}
RegCloseKey(hKey);
}
if (dwStatus == 1)
{ {
goto finish; goto finish;
} }