|
-
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;
}
-
January 12th, 2006, 02:05 AM
#2
Re: How to keep my exe running to disable print screen?
add this before the return 0
Code:
while(GetMessage(&msg, NULL, NULL, NULL))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
-
January 12th, 2006, 02:48 AM
#3
Re: How to keep my exe running to disable print screen?
leojose
What is the equivalence of your 'msg' in my code or is it a new variable to be defined?
-
January 12th, 2006, 03:01 AM
#4
Re: How to keep my exe running to disable print screen?
 Originally Posted by Kurosan
l
What is the equivalence of your 'msg' in my code or is it a new variable to be defined?
msg is a MSG Structure
So you just need to define it like this...
-
January 12th, 2006, 03:29 AM
#5
Re: How to keep my exe running to disable print screen?
Thanks leojose, it's working. Is there any way to hide my program from the Task Manager under WinXP?
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
|