如何屏蔽掉Ctrl-Alt-Del键 (200分)

  • 主题发起人 主题发起人 rating
  • 开始时间 开始时间
R

rating

Unregistered / Unconfirmed
GUEST, unregistred user!
如何屏蔽掉Ctrl-Alt-Del键,当用户按这三个见时不出现关闭程序的对话框.<br>(在Win98上用Delphi实现)<br>当窗体最小化时如何不出现在系统工具条上
 
Win2K/NT下屏蔽Ctrl+Alt+Del的响应<br>作者:陆其明 Email:luqiming@263.net &nbsp;2001-08-29<br><br>大家知道,Ctrl+Alt+Del是Win2k/NT操作系统默认的系统登录/注销组合键序列,系统级别很高。在应用程序中,想要屏蔽掉该键序列的响应或得到这个“按下”事件,难度是相当大的。本文介绍了一种简单易行的方法,实现在用户登录成功后,按下Ctrl+Alt+Del不再弹出“Windows安全”对话框。<br><br>关键词:GINA(Graphical Identification aNd Authentication)<br>SAS(Secure Attention Sequence)<br><br>一. 开发原理<br>首先介绍一下Winlogon。Windows 2000/NT有三种系统状态:没有用户登录状态、用户成功登录状态以及工作站锁定状态。Winlogon是Windows 2000/NT操作系统提供交互式登录支持的组件。Winlogon有三个组成部分:可执行文件winlogon.exe,提供图形界面认证功能的动态库Gina Dll,以及一些网络服务提供动态库Network Provider Dll。参考模型如下:<br>&nbsp;<br>winlogon.exe处理一些下层导出的接口函数,而认证策略是在Gina Dll中是独立设计的。在系统启动时,Gina Dll被winlogon.exe装载。Microsoft提供了一个默认的Gina Dll——Winnt/system32/msgina.dll,提供了标准的用户名、密码认证模式。Gina Dll是可替换的,用户可以设计自己的Gina Dll,以提供其他如智能卡、视网膜、指纹或其他一些认证机制。<br>开发自定义的Gina Dll。必须实现并导出与winlogon.exe交互的18个标准函数接口,包括WlxNegotiate、WlxInitialize、WlxLoggedOnSAS等(其他函数接口请参考Msdn)。其中WlxNegotiate是winlogon.exe调用的第一个接口函数,进行必要的版本判断,随后调用的是WlxInitialize,主要完成winlogon.exe特定版本的函数分派表向Gina Dll的传递。笔者还要说明的是WlxLoggedOnSAS函数,这个函数主要的功能是,当winlogon在登录成功状态下,接收到SAS事件,于是调用这个函数进行SAS事件的识别以及进行各事件的相应处理。<br>自定义Gina Dll的使用。比如开发的Gina Dll文件名为MyGina.dll。将该文件放到以下路径:Winnt/system32。并修改注册表,如下:<br>Key Name: /HKEY_LOCAL_MACHINE/Software/Microsoft/Windows NT/CurrentVersion/ Winlogon <br>Value Name: GinaDLL <br>Value Type: [REG_SZ]<br>Value: MyGina.dll<br>重新启动计算机MyGina.dll即投入使用。<br><br>二. 应用实例<br>应用要求:在用户登录成功状态下,按下Ctrl+Alt+Del时系统不再弹出“Widows安全”对话框。由于并不需要改变用户名、密码这种标准的认证模式,所以可以仍然使用msgina.dll中导出的函数接口,而对WlxLoggedOnSAS函数的实现进行必要的改变。<br>开发环境:Windows 2000,PII 400<br>开发工具:Microsoft Visual C++ 6.0<br>开发步骤:<br>1.新建项目,选择MFC AppWizard(dll),项目名输入为MyGina。按下“OK”后,选择Regular DLL with MFC statically linked,按下“Finish”。<br>2.使用View-&gt;ClassWizard为CmyGinaApp增加InitInstance和ExitInstance两个函数的覆盖。注意在Stdafx.h中加入#include &lt;Winwlx.h&gt;。<br>3.由于要导入msgina.dll的接口函数,所以在MyGina.h中定义接口函数变量类型,如下:<br>typedef (WINAPI * NEGOTIATE) &nbsp; &nbsp; &nbsp; (DWORD,PDWORD);<br>typedef (WINAPI * INITIALIZE) &nbsp; &nbsp; &nbsp;(LPWSTR,HANDLE,PVOID,PVOID,PVOID *);<br>typedef (WINAPI * ACTIVATE_USHELL) (PVOID,PWSTR,PWSTR,PVOID);<br>typedef (WINAPI * PARAM_PVOID) &nbsp; &nbsp; (PVOID);<br>typedef (WINAPI * DISP_STATUS) &nbsp; &nbsp; (PVOID,HDESK,DWORD,PWSTR,PWSTR);<br>typedef (WINAPI * GET_STATUS) &nbsp; &nbsp; &nbsp;(PVOID,DWORD *,PWSTR,DWORD);<br>typedef (WINAPI * LOGON_SAS) &nbsp; &nbsp; &nbsp; (PVOID,DWORD,PVOID);<br>typedef (WINAPI * LOGOUT_SAS) &nbsp; &nbsp; &nbsp;(PVOID,DWORD,PLUID,PSID,PDWORD, PHANDLE,WLX_MPR_NOTIFY_INFO,PVOID *);<br>typedef (WINAPI * NETWORK_LOAD) &nbsp; &nbsp;(PVOID,PWLX_MPR_NOTIFY_INFO);<br>typedef (WINAPI * SCR_SAVER) &nbsp; &nbsp; &nbsp; (PVOID,BOOL &nbsp;*);<br>typedef (WINAPI * SHUT_DOWN) &nbsp; &nbsp; &nbsp; (PVOID,DWORD);<br>typedef (WINAPI * START_APP) &nbsp; &nbsp; &nbsp; (PVOID,PWSTR,PVOID,PWSTR);<br>typedef (WINAPI * LOCKED_SAS) &nbsp; &nbsp; &nbsp;(PVOID,DWORD);<br>并在类CmyGinaApp中定义成员变量,如下:<br>private:<br> HMODULE &nbsp; hMsDll;<br>public:<br> NEGOTIATE &nbsp; &nbsp; &nbsp; &nbsp; MyWlxNegotiate;<br> INITIALIZE &nbsp; &nbsp; &nbsp; &nbsp;MyWlxInitialize;<br> ACTIVATE_USHELL &nbsp; MyWlxActivateUserShell;<br> PARAM_PVOID &nbsp; &nbsp; &nbsp; MyWlxDisplayLockedNotice;<br> PARAM_PVOID &nbsp; &nbsp; &nbsp; MyWlxDisplaySASNotice;<br> DISP_STATUS &nbsp; &nbsp; &nbsp; MyWlxDisplayStatusMessage;<br> GET_STATUS &nbsp; &nbsp; &nbsp; &nbsp;MyWlxGetStatusMessage;<br> PARAM_PVOID &nbsp; &nbsp; &nbsp; MyWlxIsLockOk;<br> PARAM_PVOID &nbsp; &nbsp; &nbsp; MyWlxIsLogoffOk;<br> LOGON_SAS &nbsp; &nbsp; &nbsp; &nbsp; MyWlxLoggedOnSAS;<br> LOGOUT_SAS &nbsp; &nbsp; &nbsp; &nbsp;MyWlxLoggedOutSAS;<br> PARAM_PVOID &nbsp; &nbsp; &nbsp; MyWlxLogoff;<br> NETWORK_LOAD &nbsp; &nbsp; &nbsp;MyWlxNetworkProviderLoad;<br> PARAM_PVOID &nbsp; &nbsp; &nbsp; MyWlxRemoveStatusMessage;<br> SCR_SAVER &nbsp; &nbsp; &nbsp; &nbsp; MyWlxScreenSaverNotify;<br> SHUT_DOWN &nbsp; &nbsp; &nbsp; &nbsp; MyWlxShutdown;<br> START_APP &nbsp; &nbsp; &nbsp; &nbsp; MyWlxStartApplication;<br> LOCKED_SAS &nbsp; &nbsp; &nbsp; &nbsp;MyWlxWkstaLockedSAS;<br>注意在MyGina.h中说明extern CMyGinaApp theApp;以便于程序其他地方对theApp的引用。<br>4.在MyGina.cpp中,实现InitInstance如下:<br> // 得到默认的gina dll<br> if (hMsDll == NULL)<br> {<br> hMsDll = ::LoadLibrary("msgina.dll");<br> }<br> // 导入各个接口函数<br> if (hMsDll != NULL)<br> {<br> MyWlxNegotiate = (NEGOTIATE) &nbsp; &nbsp; &nbsp; GetProcAddress(hMsDll,"WlxNegotiate");<br> MyWlxInitialize = (INITIALIZE) &nbsp; &nbsp; &nbsp;GetProcAddress(hMsDll,"WlxInitialize");<br> MyWlxActivateUserShell=(ACTIVATE_USHELL) GetProcAddress(hMsDll,"WlxActivateUserShell");<br> MyWlxDisplayLockedNotice=(PARAM_PVOID) GetProcAddress(hMsDll,"WlxDisplayLockedNotice");<br> MyWlxDisplaySASNotice &nbsp;= (PARAM_PVOID) &nbsp; &nbsp; GetProcAddress(hMsDll,"WlxDisplaySASNotice");<br> MyWlxDisplayStatusMessage=(DISP_STATUS) &nbsp; GetProcAddress(hMsDll,"WlxDisplayStatusMessage");<br> MyWlxGetStatusMessage &nbsp; &nbsp;= (GET_STATUS) &nbsp; &nbsp; &nbsp;GetProcAddress(hMsDll,"WlxGetStatusMessage");<br> MyWlxIsLockOk &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = (PARAM_PVOID) &nbsp; &nbsp; GetProcAddress(hMsDll,"WlxIsLockOk");<br> MyWlxIsLogoffOk &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = (PARAM_PVOID) &nbsp; &nbsp; GetProcAddress(hMsDll,"WlxIsLogoffOk");<br> MyWlxLoggedOnSAS &nbsp; &nbsp; &nbsp; &nbsp;= (LOGON_SAS) &nbsp; &nbsp; &nbsp; GetProcAddress(hMsDll,"WlxLoggedOnSAS");<br> MyWlxLoggedOutSAS &nbsp; &nbsp; &nbsp; = (LOGOUT_SAS) &nbsp; &nbsp; &nbsp;GetProcAddress(hMsDll,"WlxLoggedOutSAS");<br> MyWlxLogoff &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = (PARAM_PVOID) &nbsp; &nbsp; GetProcAddress(hMsDll,"WlxLogoff");<br> MyWlxNetworkProviderLoad=(NETWORK_LOAD)GetProcAddress(hMsDll,"WlxNetworkProviderLoad");<br> MyWlxRemoveStatusMessage=(PARAM_PVOID) GetProcAddress(hMsDll,"WlxRemoveStatusMessage");<br> MyWlxScreenSaverNotify = (SCR_SAVER) &nbsp; &nbsp;GetProcAddress(hMsDll,"WlxScreenSaverNotify");<br> MyWlxShutdown &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; = (SHUT_DOWN) &nbsp; &nbsp; &nbsp; GetProcAddress(hMsDll,"WlxShutdown");<br> MyWlxStartApplication &nbsp; &nbsp; = (START_APP) &nbsp; &nbsp; &nbsp; GetProcAddress(hMsDll,"WlxStartApplication");<br> MyWlxWkstaLockedSAS &nbsp; = (LOCKED_SAS) &nbsp; &nbsp; GetProcAddress(hMsDll,"WlxWkstaLockedSAS");<br> }<br>实现ExitInstance如下:<br> // 卸载dll<br> if (hMsDll != NULL)<br> {<br> ::FreeLibrary(hMsDll);<br> hMsDll = NULL;<br> }<br>5.实现接口函数。由于本应用仍然保持msgina.dll的大部分操作,所以MyGina.dll的接口函数的实现较为简单。重点需要注意的是WlxLoggedOnSAS函数的实现。当在成功登录状态下,不管接收到什么SAS事件,该函数直接返回WLX_SAS_ACTION_NONE而不做其他处理。由于实现的函数较多(必须的18个),笔者仅列出代表性的五个,其余的依理类推。<br>// Winlogon.exe调用的gina dll中的第一个函数<br>// 使gina dll确认是否支持当前版本的Winlogon.exe<br>// 传递给winlogon.exe需要那个版本的接口函数<br>BOOL WINAPI WlxNegotiate(DWORD dwWinLogonVersion, PDWORD pdwDllVersion)<br>{<br>// 直接调用从msgina.dll中导入的函数<br> return theApp.MyWlxNegotiate(dwWinLogonVersion,pdwDllVersion);<br>}<br>// 初始化,winlogon.exe向gina dll传递需要版本的接口函数分配表<br>BOOL WINAPI WlxInitialize(LPWSTR &nbsp; &nbsp;lpWinsta,<br> &nbsp;HANDLE &nbsp; &nbsp;hWlx,<br> &nbsp;PVOID &nbsp; &nbsp; pvReserved,<br> &nbsp;PVOID &nbsp; &nbsp; pWinlogonFunctions,<br> &nbsp;PVOID * &nbsp; pWlxContext<br> &nbsp;)<br>{<br>// 直接调用从msgina.dll中导入的函数<br> return theApp.MyWlxInitialize(lpWinsta,hWlx,pvReserved,pWinlogonFunctions,pWlxContext);<br>}<br>// 当系统处于锁定状态时,Winlogon.exe调用该函数<br>// 显示一些信息,如锁定者、锁定时间等<br>VOID WINAPI WlxDisplayLockedNotice(PVOID pWlxContext)<br>{<br> theApp.MyWlxDisplayLockedNotice(pWlxContext);<br>}<br>// 在系统关闭之前,Winlogon.exe调用该函数<br>// 允许gina dll处理一些系统关闭前的处理<br>VOID WINAPI WlxShutdown(PVOID pWlxContext, DWORD ShutdownType)<br>{<br> theApp.MyWlxShutdown(pWlxContext,ShutdownType);<br>}<br>// 当系统处于登陆成功,没有锁定的状态下<br>// Winlogon接收到SAS事件,于是调用该函数<br>// 现屏蔽所有事件,直接返回<br>int WINAPI WlxLoggedOnSAS(PVOID pWlxContext,<br> &nbsp;DWORD dwSasType,<br> &nbsp;PVOID pReserved)<br>{<br> return WLX_SAS_ACTION_NONE;<br>}<br>6.将MyGina.dll中实现的所有接口函数,在MyGina.def中定义导出。<br>
 
如何在98下用delphi实现
 
屏蔽三个键!<br>var<br>  temp : integer;<br>  begin<br>   SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @temp, 0);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;~(0为取消!)<br>  end;<br>
 
98下用foundworld的方法就可以了<br>最小化时不出现可以让application的showmailform为false
 
var<br>&nbsp; &nbsp; temp: Integer;<br>begin<br>&nbsp; &nbsp; //隐藏任务栏图标<br>&nbsp; &nbsp; SetWindowLong(Application.Handle,GWL_EXSTYLE,WS_EX_TOOLWINDOW);<br>&nbsp; &nbsp; //屏蔽功能键<br>&nbsp; &nbsp; SystemParametersInfo(Spi_screensaverrunning,1,@temp,0);<br>&nbsp; &nbsp; //恢复系统功能键<br>&nbsp; &nbsp; //SystemParametersInfo(spi_screensaverrunning,0,@temp,0);<br>end;<br>
 
agreed 春意,但是在win2000下不能屏蔽系统功能键
 
多人接受答案了。
 
后退
顶部