IonicWind Software

IWBasic => GUI Central => Topic started by: paja on February 12, 2010, 05:28:11 PM

Title: CTRL+ALT+DEL and ALT+F4 disable ?
Post by: paja on February 12, 2010, 05:28:11 PM
Hi.

How can I disable from program  keyboard control combination "CTRL+ALT+DEL" and "ALT+F4" ?

Thanks
Title: Re: CTRL+ALT+DEL and ALT+F4 disable ?
Post by: Doc on February 12, 2010, 05:52:59 PM
Quote from: paja on February 12, 2010, 05:28:11 PM
Hi.

How can I disable from program  keyboard control combination "CTRL+ALT+DEL" and "ALT+F4" ?

Thanks


I certainly hope that I do not offend or cast a shadow of "evil intent" your direction, but I wouldn't want a program with those capabilities to be found anywhere on my computer. Nor can I think of any good reasoning to add such.

Smileys go here to show that I'm not trying to be mean spirited or cause a problem. :) :) :)
...rather just a very specific point of view.  ;D

-Doc-
Title: Re: CTRL+ALT+DEL and ALT+F4 disable ?
Post by: ZeroDog on February 14, 2010, 06:47:57 AM
sometimes you want to be able to control the ability to close the running program, or prevent the task manager from being accessed.  A good example of this is a kiosk.  You dont want people having access to anything but the kiosk software that is running.

There is a good article here  (http://msdn.microsoft.com/en-ca/magazine/cc188951.aspx) on how to do it.  Its in c++ but the theory is the same for EBasic.


EDIT:fixed link oops !
Title: Re: CTRL+ALT+DEL and ALT+F4 disable ?
Post by: Doc on February 14, 2010, 07:47:21 AM
Quotesometimes you want to be able to control the ability to close the running program, or prevent the task manager from being accessed.

Which is true... 
However, for most of the questions I've seen such as this over the years, it seems there is all too often, ill intentions (like a mean prank or even worse) involved. I stand corrected.

I apologize if I sounded too harsh, paja.   :-[

-Doc-
Title: Re: CTRL+ALT+DEL and ALT+F4 disable ?
Post by: paja on February 14, 2010, 08:25:02 AM
The link is wrong
Title: Re: CTRL+ALT+DEL and ALT+F4 disable ?
Post by: Copex on February 15, 2010, 03:23:32 AM

it should be........

http://msdn.microsoft.com/en-ca/magazine/cc188951.aspx
Title: Re: CTRL+ALT+DEL and ALT+F4 disable ?
Post by: pistol350 on February 15, 2010, 05:51:12 AM
I found this sample code that may be very useful for what you're trying to accomplish :
It's about low level hooks

$include "windows.inc"

type KBDLLHOOKSTRUCT
   int vkCode
   int scanCode
   int flags
   int time
   pointer dwExtraInfo
endtype

const LLKHF_ALTDOWN = (0x2000 >> 8)
const WH_KEYBOARD_LL = 13

'LRESULT CALLBACK LowLevelKeyboardProc(int nCode,
'   WPARAM wParam, LPARAM lParam) {
sub LowLevelKeyboardProc(nCode:int, wParam:uint, lParam:pointer)

'   bool fEatKeystroke = FALSE;
   int fEatKeystroke = false

'   if (nCode == HC_ACTION) {
   if (nCode = HC_ACTION)
'      switch (wParam) {
      select (wParam)
'      case WM_KEYDOWN:  case WM_SYSKEYDOWN:
'      case WM_KEYUP:    case WM_SYSKEYUP:
      case WM_KEYDOWN
      case& WM_SYSKEYDOWN
      case& WM_KEYUP
      case& WM_SYSKEYUP
'         PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
         KBDLLHOOKSTRUCT p : p = *<KBDLLHOOKSTRUCT>lParam
         
'         fEatKeystroke =
'            ((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
'            ((p->vkCode == VK_ESCAPE) &&
'            ((p->flags & LLKHF_ALTDOWN) != 0)) ||
'            ((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) &
'             0x8000) != 0)) ||
'             ((p->vkCode == VK_DELETE) ((GetKeyState(VK_CONTROL) &
'             0x8000) != 0) && (p->flags & LLKHF_ALTDOWN != 0)) ;
         fEatKeystroke = _
            ((p.vkCode = VK_TAB) and ((p.flags & LLKHF_ALTDOWN) <> 0)) or _
            ((p.vkCode = VK_ESCAPE) and ((p.flags & LLKHF_ALTDOWN) <> 0)) or _
            ((p.vkCode = VK_ESCAPE) and ((_GetKeyState(VK_CONTROL) & 0x8000) <> 0)) or _
((p.vkCode = VK_DELETE) and ((_GetKeyState(VK_CONTROL) & 0x8000) <> 0) and (p.flags & LLKHF_ALTDOWN) <> 0)
'         break;
'      }
      endselect
'   }
   endif
   if (fEatKeystroke) then return 1 else return _CallNextHookEx(NULL, nCode, wParam, lParam)
'   return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam,
'          lParam));
'}
endsub

'/////////////////////////////////////////////////////////////////////////


'int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) {

'   // Install the low-level keyboard & mouse hooks
'   HHOOK hhkLowLevelKybd  = SetWindowsHookEx(WH_KEYBOARD_LL,
'      LowLevelKeyboardProc, hinstExe, 0);
   int hhkLowLevelKybd
   hhkLowLevelKybd = _SetWindowsHookEx(WH_KEYBOARD_LL, &LowLevelKeyboardProc, _GetModuleHandle(NULL), 0)

'   // Keep this app running until we're told to stop
'   MessageBox(NULL,
'      TEXT("Alt+Esc, Ctrl+Esc, and Alt+Tab are now disabled.\n")
'      TEXT("Click \"Ok\" to terminate this application and re-enable
'            these keys."),
'      TEXT("Disable Low-Level Keys"), 4);
   messagebox(Null, "Alt+Esc, Ctrl+Esc, Alt+Tab and Ctrl+Alt+Del are now disabled.\n" + _
      "Click \"Ok\" to terminate this application and re-enable these keys.", "Disable Low-Level Keys", 0)
   _UnhookWindowsHookEx(hhkLowLevelKybd)

'   return(0);
'}
'#endif
Title: Re: CTRL+ALT+DEL and ALT+F4 disable ?
Post by: paja on February 17, 2010, 01:01:42 PM
Ctrl+Alt+Del  + key "WINDOWS" do not work still. Other yes. I have WIN 7 64 bit