hook需要释放

This commit is contained in:
awin-x 2025-01-26 14:36:55 +08:00
parent a1bfb5b273
commit 6694675d1a

View File

@ -13,6 +13,7 @@ LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam);
Gdiplus::Graphics* graphics; Gdiplus::Graphics* graphics;
ULONG_PTR gdiplusToken; ULONG_PTR gdiplusToken;
HWND hwnd; HWND hwnd;
HHOOK hook;
mutex mtx; mutex mtx;
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
@ -41,8 +42,7 @@ int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszA
} }
CreateFullScreenTransparentWindow(L"報炎蒙丼", L"cursor_anim"); CreateFullScreenTransparentWindow(L"報炎蒙丼", L"cursor_anim");
HHOOK hook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0); hook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0);
// 幹秀<E5B9B9> // 幹秀<E5B9B9>
@ -122,6 +122,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
delete graphics; delete graphics;
UnregisterHotKey(hwnd, g_hotkeyId); UnregisterHotKey(hwnd, g_hotkeyId);
Gdiplus::GdiplusShutdown(gdiplusToken); Gdiplus::GdiplusShutdown(gdiplusToken);
UnhookWindowsHookEx(hook);
PostQuitMessage(0); PostQuitMessage(0);
break; break;
} }