I want to setup a System wide hook to listen for WM_DEVICECHANGE in C++. I know that hooks are setup using SetWindowsHookEx(). I have done this before for Keyboard messages (WM_KEYUP, WM_KEYDOWN) but I want to do it for WM_DEVICECHANGE. I am currently using:
void WinHook()
{
HHOOK hook = NULL;
hook = SetWindowsHookEx(WH_GETMESSAGE, HookProc, NULL, GetCurrentThreadId());
}
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam){
switch (wParam){
case WM_DEVICECHANGE:std::cout << "SUCCESS!!!!!";
break;
}
}
Aucun commentaire:
Enregistrer un commentaire