| #include <windows.h> HHOOK hHook; LRESULT __stdcall CBTHookProc( long nCode,WPARAM wParam,LPARAM lParam); int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow) { hHook=SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,hInst,NULL); if (hHook) { MessageBox(NULL,"你是帅哥吗?","SC++",MB_ICONINFORMATION|MB_YESNO); } else { MessageBox(NULL,"无法安装HOOK" ,"SC++",MB_ICONINFORMATION|MB_YESNO); }//if return 1; } LRESULT __stdcall CBTHookProc( long nCode,WPARAM wParam,LPARAM lParam) { if (nCode==HCBT_ACTIVATE) { SetDlgItemText((HWND)wParam,IDYES,"&Yes"); SetDlgItemText((HWND)wParam,IDNO ,"&No"); UnhookWindowsHookEx(hHook); } return 0; } |