|
-
January 12th, 2006, 01:56 AM
#1
How to keep my exe running to disable print screen?
I'm using the following code to disable print screen. The problem is that my program will terminate once it hits the "return 0" statement in WinMain() , how to keep my exe program running so as to enforce the disabling?
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam);
typedef UINT (CALLBACK* LPREGISTERSERVICEPROC)(DWORD,DWORD);
HHOOK hhkLowLevelKybd;
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
BOOL fSuppressKeystroke = FALSE;
if (nCode == HC_ACTION) {
switch (wParam) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT)lParam;
fSuppressKeystroke = ((p->vkCode == VK_SNAPSHOT));
break;
}
}
return (fSuppressKeystroke? 1: CallNextHookEx(NULL, nCode, wParam, lParam));
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, PTSTR pszCmdLine, int nCmdShow)
{
// start disabling the PrintScreen key
hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, hInstance, 0);
return 0;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|