屏蔽Ctrl+Alt+Del键(40分)

  • 主题发起人 主题发起人 yeah
  • 开始时间 开始时间
Y

yeah

Unregistered / Unconfirmed
GUEST, unregistred user!
我编写了一个游戏管理软件,在启动时使用以下过程屏蔽热启动键及Alt+Tab<br>等:<br>procedure LockSystem(Flag:Boolean);<br>var temp:Integer;<br>begin<br>SystemParamMeterInfo(SPI_SCREENSAVERUNNING,Word(Flag),@temp,0);<br>end;<br><br>但是,只要一运行用DirectX编程的游戏如:Commandos,BloodWar,redAlert等,则Ctrl+Alt+Del,Alt+Tab等键的功能自动被恢复了!
 
是这样吗,我没有太好的解决办法,但我有一个变通的办法:<br>因为你肯定是单任务形式的,所以你可以用CreateProcess创建进程,等待进程结束<br>后,重新LockSystem,这是一个单任务的函数,你程序里调用就行了(我也是超的):<br><br>function WinExecAndWait32(FileName:String; Visibility : integer):integer;<br>var<br>&nbsp; zAppName:array[0..512] of char;<br>&nbsp; zCurDir:array[0..255] of char;<br>&nbsp; WorkDir:String;<br>&nbsp; StartupInfo:TStartupInfo;<br>&nbsp; ProcessInfo:TProcessInformation;<br>&nbsp; tmp :DWORD;<br>begin<br>&nbsp; StrPCopy(zAppName,FileName);<br>&nbsp; GetDir(0,WorkDir);<br>&nbsp; StrPCopy(zCurDir,WorkDir);<br>&nbsp; FillChar(StartupInfo,Sizeof(StartupInfo),#0);<br>&nbsp; StartupInfo.cb := Sizeof(StartupInfo);<br>&nbsp; StartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br>&nbsp; StartupInfo.wShowWindow := Visibility;<br>&nbsp; if not CreateProcess(nil,<br>&nbsp; &nbsp; zAppName, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ pointer to command line string }<br>&nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to process security attributes }<br>&nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to thread security attributes }<br>&nbsp; &nbsp; false, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { handle inheritance flag }<br>&nbsp; &nbsp; CREATE_NEW_CONSOLE or &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ creation flags }<br>&nbsp; &nbsp; NORMAL_PRIORITY_CLASS,<br>&nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to new environment block }<br>&nbsp; &nbsp; nil, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to current directory name }<br>&nbsp; &nbsp; StartupInfo, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { pointer to STARTUPINFO }<br>&nbsp; &nbsp; ProcessInfo) then<br>&nbsp; &nbsp; Result := -1 { pointer to PROCESS_INF }<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; WaitforSingleObject(ProcessInfo.hProcess,INFINITE);<br>&nbsp; &nbsp; &nbsp; GetExitCodeProcess(ProcessInfo.hProcess,tmp);<br>&nbsp; &nbsp; &nbsp; Result := tmp;<br>&nbsp; &nbsp; end;<br>end;<br><br>不知有没有更好的办法??
 
总觉得不爽:(<br>急切关注!能否用点 DIRECTX 函数什么的?//瞎说
 
我建议你将屏蔽过过程放入TApplication的事件(如onactivate,onidle...)中,<br>而不是只放在create中。
 
或者做个定时器,每隔5秒屏蔽一次?
 
到http://shrw.chn.net去找!
 
我记得编过一个用DDRAW的程序,在启动时就屏蔽的话,是没有效果的.<br>必须在DDRAW启动以后再屏蔽才可以.定时屏蔽应该是可以的吧.
 
procedure TForm1.FormCreate(Sender: TObject);  <br>var tmp:integer; <br>begin<br>  tmp := 0;<br><br>  //屏蔽 Alt-Tab <br>  SystemParametersInfo( SPI_SETFASTTASKSWITCH, 1, @tmp, 0); <br><br>  //屏蔽 Ctrl-Alt-Del<br>  SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @tmp, 0);   <br>end;<br>
 
可以用 SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @Oldvalus, 0)<br>告诉windows屏幕保护程序正在运行,系统就会屏蔽按键和鼠标动作。<br>
 
<br>和datoncg 一样:<br>用 SystemParametersInfo函数:<br>  <br>  //屏蔽 Ctrl-Alt-Del<br>  SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @tmp, 0);   <br>end;<br><br>&nbsp;<br>&nbsp;<br><br><br>
 
接受答案了.
 

Similar threads

后退
顶部