禁用控制+ ALT + DELETE和在Windows 7中使用Win32应用程序的Windows(WIN)关键 [英] Disable CONTROL + ALT + DELETE and Windows(win) Key in Windows 7 using Win32 application

查看:344
本文介绍了禁用控制+ ALT + DELETE和在Windows 7中使用Win32应用程序的Windows(WIN)关键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写它运行像亭应用,应该允许用户外出应用程序。在 Windows 7的,当他presses的<大骨节病>赢 CTRL + <大骨节病> ALT + <大骨节病>删除,它出来的方案。我需要禁用<大骨节病>控制 + <大骨节病> ALT + <大骨节病>删除组合键和<大骨节病>在键Windows 7的编程。

I am writing an application which runs like a kiosk and should allow user to go out of the application. In Windows 7 , when he presses the Win key or CTRL + ALT+ DELETE , it comes out of program. I need to disable the Ctrl+ ALT + DELETE combination key and Win key in Windows 7 programmatically.

推荐答案

pressing <大骨节病>替代 + <大骨节病>标签将转出的应用程序,也。 <大骨节病>控制 + <大骨节病> ESC 是打开开始菜单中的备用快捷方式。 <大骨节病>替代 +运行的应用程序之间的<大骨节病> ESC 翻转。有一些可以做到这一点不同的密钥序列;是的Windows多任务操作系统的自然结果。

Pressing Alt+Tab will switch out of the application, also. Ctrl+Esc is an alternate shortcut for opening the Start menu. Alt+Esc flips between running applications. There a number of different key sequences that can do this; a natural consequence of Windows being a multitasking operating system.

要解决这个问题,你将必须安装一个低级别的键盘钩子,可以捕获这些任务按键。钩子必须被实现为一个DLL,它会观看为任何用于切换任务的公共密钥序列。只要检测那些序列之一,它将忽略通过不传递下来的钩链的输入端。作者简介Paul DiLascia写道,在MSDN杂志的2002年9月版解决过这个问题的文章。您所关心的部分大约一半的开工率下降的页面,但我在这里转载它的方便和获得语法高亮的乐趣:

To work around this, you're going to have to install a low-level keyboard hook that can trap these task keys. The hook must be implemented as a DLL, and it will watch for any of the common key sequences used to switch tasks. Whenever it detects one of those sequences, it will ignore the input by not passing it down the hook chain. Paul DiLascia wrote an article that addresses this very question in the September 2002 edition of MSDN Magazine. The part you care about starts about halfway down the page, but I've reprinted it here for convenience and to get the pleasures of syntax highlighting:

TaskKeyHook.h:

TaskKeyHook.h:

////////////////////////////////////////////////////////////////
// MSDN Magazine — September 2002
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual Studio 6.0 and Visual Studio .NET on Windows XP.
//
#define DLLIMPORT __declspec(dllimport)

DLLIMPORT BOOL DisableTaskKeys(BOOL bEnable, BOOL bBeep);
DLLIMPORT BOOL AreTaskKeysDisabled();

TaskKeyHook.cpp

TaskKeyHook.cpp

////////////////////////////////////////////////////////////////
// MSDN Magazine — September 2002
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual Studio 6.0 and Visual Studio .NET on Windows XP.
//
// This file implements the low-level keyboard hook that traps the task 
// keys.
//
#define _WIN32_WINNT 0x0500 // for KBDLLHOOKSTRUCT
#include <afxwin.h>         // MFC core and standard components

#define DLLEXPORT __declspec(dllexport)

//////////////////
// App (DLL) object
//
class CTaskKeyHookDll : public CWinApp {
public:
   CTaskKeyHookDll()  { }
   ~CTaskKeyHookDll() { }
} MyDll;

////////////////
// The section is SHARED among all instances of this DLL.
// A low-level keyboard hook is always a system-wide hook.
// 
#pragma data_seg (".mydata")
HHOOK g_hHookKbdLL = NULL; // hook handle
BOOL  g_bBeep = FALSE;     // beep on illegal key
#pragma data_seg ()
#pragma comment(linker, "/SECTION:.mydata,RWS") // tell linker: make it 
                                                // shared

/////////////////
// Low-level keyboard hook:
// Trap task-switching keys by returning without passing along.
//
LRESULT CALLBACK MyTaskKeyHookLL(int nCode, WPARAM wp, LPARAM lp)
{
   KBDLLHOOKSTRUCT *pkh = (KBDLLHOOKSTRUCT *) lp;

   if (nCode==HC_ACTION) {
      BOOL bCtrlKeyDown =
         GetAsyncKeyState(VK_CONTROL)>>((sizeof(SHORT) * 8) - 1);

      if ((pkh->vkCode==VK_ESCAPE && bCtrlKeyDown) || // Ctrl+Esc
          // Alt+TAB
          (pkh->vkCode==VK_TAB && pkh->flags & LLKHF_ALTDOWN) ||   
          // Alt+Esc
          (pkh->vkCode==VK_ESCAPE && pkh->flags & LLKHF_ALTDOWN)|| 
          (pkh->vkCode==VK_LWIN || pkh->vkCode==VK_RWIN)) { // Start Menu
         if (g_bBeep && (wp==WM_SYSKEYDOWN||wp==WM_KEYDOWN))
            MessageBeep(0); // only beep on downstroke if requested
         return 1; // gobble it: go directly to jail, do not pass go
      }
   }
   return CallNextHookEx(g_hHookKbdLL, nCode, wp, lp);
}

//////////////////
// Are task keys disabled—ie, is hook installed?
// Note: This assumes there's no other hook that does the same thing!
//
DLLEXPORT BOOL AreTaskKeysDisabled()
{
   return g_hHookKbdLL != NULL;
}

//////////////////
// Disable task keys: install low-level kbd hook.
// Return whether currently disabled or not.
//
DLLEXPORT BOOL DisableTaskKeys(BOOL bDisable, BOOL bBeep)
{
   if (bDisable) {
      if (!g_hHookKbdLL) {
         g_hHookKbdLL = SetWindowsHookEx(WH_KEYBOARD_LL,
            MyTaskKeyHookLL, MyDll.m_hInstance, 0);
      }

   } else if (g_hHookKbdLL != NULL) {
      UnhookWindowsHookEx(g_hHookKbdLL);
      g_hHookKbdLL = NULL;
   }
   g_bBeep = bBeep;

   return AreTaskKeysDisabled();
}

他还提供样品code禁用任务栏(因此preventing从显示开始菜单Windows键),并使用这些库的一个完整的示例应用程序。

He also provides sample code to disable the taskbar (thus preventing the Windows key from showing the Start menu) and a complete sample application that uses these libraries.

至于preventing <大骨节病>控制 + <大骨节病>替代 + <大骨节病>删除(安全警告序列或SAS),上面的方法是行不通的。其原因是,在OS捕获由SAS从其它键中断产生的硬件分开,专门从钩住序列和欺骗登录提示prevent程序。你是不是要能够用键盘钩子禁用此功能。我联系到上述文章确实覆盖顶部很详细的这一要求,但这些战略只是测试更可能只能在Windows XP中运行。本文所建议的另一种方法是禁用任务管理器,但请注意,这将不会从关闭系统,等的右键的方式做到这一点停止用户是写一个键盘驱动程序。

As far as preventing Ctrl+Alt+Del (the secure attention sequence, or SAS), the above approach is not going to work. The reason is that the OS traps the hardware interrupt generated by the SAS separately from other keys, specifically to prevent programs from hooking the sequence and spoofing a login prompt. You aren't going to be able to disable this feature with a keyboard hook. The article I linked to above does cover this requirement in great detail at the top portion, but those strategies are only tested and more than likely will only work on Windows XP. Another approach suggested by the article is to disable the Task Manager, but note that that won't stop the user from shutting down the system, etc. The right way to do this is to write a keyboard driver.

这篇关于禁用控制+ ALT + DELETE和在Windows 7中使用Win32应用程序的Windows(WIN)关键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆