mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-30 18:24:36 +01:00
Ground work for supporting OpenAtLogon
This commit is contained in:
parent
e50d1d1f56
commit
c400f4d6ab
@ -1090,45 +1090,8 @@ HRESULT CImmersiveHotkeyNotification_OnMessageHook(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slightly tweaked version of function available in Open Shell
|
void OpenStartOnMonitor(HMONITOR monitor)
|
||||||
// (Open-Shell-Menu\Src\StartMenu\StartMenuHelper\StartMenuHelper.cpp)
|
|
||||||
LRESULT CALLBACK OpenStartOnCurentMonitorThreadHook(
|
|
||||||
int code,
|
|
||||||
WPARAM wParam,
|
|
||||||
LPARAM lParam
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (code == HC_ACTION && wParam)
|
|
||||||
{
|
|
||||||
MSG* msg = (MSG*)lParam;
|
|
||||||
if (GetSystemMetrics(SM_CMONITORS) >= 2 && msg->message == WM_SYSCOMMAND && (msg->wParam & 0xFFF0) == SC_TASKLIST)
|
|
||||||
{
|
|
||||||
DWORD dwStatus = 0;
|
|
||||||
DWORD dwSize = sizeof(DWORD);
|
|
||||||
HMODULE hModule = GetModuleHandle(TEXT("Shlwapi"));
|
|
||||||
FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM");
|
|
||||||
LSTATUS x = 0;
|
|
||||||
if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc(
|
|
||||||
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"),
|
|
||||||
TEXT("MonitorOverride"),
|
|
||||||
SRRF_RT_REG_DWORD,
|
|
||||||
NULL,
|
|
||||||
&dwStatus,
|
|
||||||
(LPDWORD)(&dwSize)
|
|
||||||
) != ERROR_SUCCESS || dwStatus == 1)
|
|
||||||
{
|
|
||||||
goto finish;
|
|
||||||
}
|
|
||||||
|
|
||||||
DWORD pts = GetMessagePos();
|
|
||||||
POINT pt;
|
|
||||||
pt.x = GET_X_LPARAM(pts);
|
|
||||||
pt.y = GET_Y_LPARAM(pts);
|
|
||||||
HMONITOR monitor = MonitorFromPoint(
|
|
||||||
pt,
|
|
||||||
MONITOR_DEFAULTTONULL
|
|
||||||
);
|
|
||||||
|
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
IUnknown* pImmersiveShell = NULL;
|
IUnknown* pImmersiveShell = NULL;
|
||||||
hr = CoCreateInstance(
|
hr = CoCreateInstance(
|
||||||
@ -1191,6 +1154,46 @@ LRESULT CALLBACK OpenStartOnCurentMonitorThreadHook(
|
|||||||
}
|
}
|
||||||
pImmersiveShell->lpVtbl->Release(pImmersiveShell);
|
pImmersiveShell->lpVtbl->Release(pImmersiveShell);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slightly tweaked version of function available in Open Shell
|
||||||
|
// (Open-Shell-Menu\Src\StartMenu\StartMenuHelper\StartMenuHelper.cpp)
|
||||||
|
LRESULT CALLBACK OpenStartOnCurentMonitorThreadHook(
|
||||||
|
int code,
|
||||||
|
WPARAM wParam,
|
||||||
|
LPARAM lParam
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (code == HC_ACTION && wParam)
|
||||||
|
{
|
||||||
|
MSG* msg = (MSG*)lParam;
|
||||||
|
if (GetSystemMetrics(SM_CMONITORS) >= 2 && msg->message == WM_SYSCOMMAND && (msg->wParam & 0xFFF0) == SC_TASKLIST)
|
||||||
|
{
|
||||||
|
DWORD dwStatus = 0;
|
||||||
|
DWORD dwSize = sizeof(DWORD);
|
||||||
|
HMODULE hModule = GetModuleHandle(TEXT("Shlwapi"));
|
||||||
|
FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM");
|
||||||
|
if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc(
|
||||||
|
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"),
|
||||||
|
TEXT("MonitorOverride"),
|
||||||
|
SRRF_RT_REG_DWORD,
|
||||||
|
NULL,
|
||||||
|
&dwStatus,
|
||||||
|
(LPDWORD)(&dwSize)
|
||||||
|
) != ERROR_SUCCESS || dwStatus == 1)
|
||||||
|
{
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD pts = GetMessagePos();
|
||||||
|
POINT pt;
|
||||||
|
pt.x = GET_X_LPARAM(pts);
|
||||||
|
pt.y = GET_Y_LPARAM(pts);
|
||||||
|
HMONITOR monitor = MonitorFromPoint(
|
||||||
|
pt,
|
||||||
|
MONITOR_DEFAULTTONULL
|
||||||
|
);
|
||||||
|
OpenStartOnMonitor(monitor);
|
||||||
|
|
||||||
msg->message = WM_NULL;
|
msg->message = WM_NULL;
|
||||||
}
|
}
|
||||||
@ -1316,35 +1319,57 @@ DWORD OpenStartOnCurentMonitorThread(LPVOID unused)
|
|||||||
printf("Ended \"Open Start on current monitor\" thread.\n");
|
printf("Ended \"Open Start on current monitor\" thread.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD PlayStartupSound(DWORD x)
|
DWORD OpenStartAtLogon(DWORD unused)
|
||||||
|
{
|
||||||
|
HANDLE hEvent = CreateEvent(0, 0, 0, L"ShellDesktopSwitchEvent");
|
||||||
|
if (!hEvent)
|
||||||
|
{
|
||||||
|
printf("Failed to start \"Open Start at Logon\" thread.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
WaitForSingleObject(
|
||||||
|
hEvent,
|
||||||
|
INFINITE
|
||||||
|
);
|
||||||
|
printf("Started \"Open Start at Logon\" thread.\n");
|
||||||
|
|
||||||
|
DWORD dwStatus = 0;
|
||||||
|
DWORD dwSize = sizeof(DWORD);
|
||||||
|
HMODULE hModule = GetModuleHandle(TEXT("Shlwapi"));
|
||||||
|
FARPROC SHRegGetValueFromHKCUHKLMFunc = GetProcAddress(hModule, "SHRegGetValueFromHKCUHKLM");
|
||||||
|
if (!SHRegGetValueFromHKCUHKLMFunc || SHRegGetValueFromHKCUHKLMFunc(
|
||||||
|
TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage"),
|
||||||
|
TEXT("OpenAtLogon"),
|
||||||
|
SRRF_RT_REG_DWORD,
|
||||||
|
NULL,
|
||||||
|
&dwStatus,
|
||||||
|
(LPDWORD)(&dwSize)
|
||||||
|
) != ERROR_SUCCESS || dwStatus == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
POINT pt;
|
||||||
|
pt.x = 0;
|
||||||
|
pt.y = 0;
|
||||||
|
HMONITOR monitor = MonitorFromPoint(
|
||||||
|
pt,
|
||||||
|
MONITOR_DEFAULTTOPRIMARY
|
||||||
|
);
|
||||||
|
OpenStartOnMonitor(monitor);
|
||||||
|
|
||||||
|
printf("Ended \"Open Start at Logon\" thread.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD PlayStartupSound(DWORD unused)
|
||||||
{
|
{
|
||||||
Sleep(2000);
|
Sleep(2000);
|
||||||
printf("Started \"Play startup sound\" thread.\n");
|
printf("Started \"Play startup sound\" thread.\n");
|
||||||
|
|
||||||
HRESULT hr = CoInitialize(NULL);
|
HRESULT hr = CoInitialize(NULL);
|
||||||
|
|
||||||
/*HKEY hKey2;
|
// this checks Software\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI\\LogonSoundPlayed
|
||||||
LONG lRes2 = RegOpenKeyExW(
|
// and then plays the startup sound
|
||||||
HKEY_LOCAL_MACHINE,
|
|
||||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI\\LogonSoundPlayed",
|
|
||||||
0,
|
|
||||||
KEY_READ,
|
|
||||||
&hKey2
|
|
||||||
);
|
|
||||||
if (lRes2 == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
DWORD val = 5;
|
|
||||||
DWORD szval = 4;
|
|
||||||
lRes2 = RegQueryValueExW(
|
|
||||||
hKey2,
|
|
||||||
L"SoundPlayed",
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
&val,
|
|
||||||
&szval
|
|
||||||
);
|
|
||||||
printf("SoundPlayed: %d %d\n", val, lRes2);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
AuthUILogonSound* ppv;
|
AuthUILogonSound* ppv;
|
||||||
hr = CoCreateInstance(
|
hr = CoCreateInstance(
|
||||||
@ -1364,7 +1389,7 @@ DWORD PlayStartupSound(DWORD x)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD SignalShellReady(DWORD x)
|
DWORD SignalShellReady(DWORD unused)
|
||||||
{
|
{
|
||||||
Sleep(2000);
|
Sleep(2000);
|
||||||
printf("Started \"Signal shell ready\" thread.\n");
|
printf("Started \"Signal shell ready\" thread.\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user