我写了一个小程序,它连接到键盘并更改按键上的注册表值。这是回调代码:
LRESULT WINAPI keyDownEvent(int nCode, WPARAM wParam, LPARAM lParam)
{
if ((wParam == WM_SYSKEYDOWN) || (wParam == WM_KEYDOWN))
{
KBDLLHOOKSTRUCT kbdStruct = *(((KBDLLHOOKSTRUCT *) lParam));
if ((kbdStruct.vkCode == VK_LWIN) || (kbdStruct.vkCode == VK_RWIN))
{
RegSetValueEx(key, TEXT("MakeAllAppsDefault"), NULL, REG_DWORD, (const BYTE*) DISABLE_APPS_VIEW, sizeof(DISABLE_APPS_VIEW)); // Set value to 0 (OFF)
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam); // Pass info to next hook procedure
}
RegSetValueEx == ERROR_SUCCESS 的返回值,表示正在设置该值,但是当我打开注册表时,该值仍然相同。有什么我做错了吗?
DWORD DISABLE_APPS_VIEW = 0;
DWORD ENABLE_APPS_VIEW = 1;