Is there a way to disable the 'Print Scrn' key to prevent screen capturing?
Printable View
Is there a way to disable the 'Print Scrn' key to prevent screen capturing?
Yep there sure is a way to disable the print screen key. You can do it using low level keyboard hooks. Here is the code to disable the print screen key.
Hope this helps!
Cheers,
Greg
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));
}
//Call this when you want to start capturing the printscreen key
hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, hInstance, 0);
//call this to stop disabling the print screen key
UnhookWindowsHookEx(hhkLowLevelKybd);
a perfect answer!:)
Thanks for the help.
The code is for NT/2K/XP, how about Win9x ?
I changed the parameter from WH_KEYBOARD_LL to WH_KEYBOARD and it doesn't work in Win9x.
oooh... windows9x...
I am at work right now, and we don't have any windows 9x boxes around here anymore :(
I have some win 9x machines at home, so when I get home I will try to see if I can get you a solution for win 9x.
Cheers,
Greg
I haven't tried it yet, but to disable the print screen key in windows 98 you might try registering that key as a hotkey and just make it do nothing.
You could check out this article
http://www.codeproject.com/system/nishhotkeys01.asp
Cheers,
Greg