请教:想写个小工具,运行后立即关闭监视器并且锁定系统,(100分)

  • 主题发起人 主题发起人 geoffrey
  • 开始时间 开始时间
G

geoffrey

Unregistered / Unconfirmed
GUEST, unregistred user!
只响应特定的热键才能打开监视器。<br>用delphi怎么实现?
 
关闭显示器:<br>SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 0);<br>打开显示器:<br>SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, -1);<br><br>锁定系统:<br>function LockWS: Boolean;<br>type<br> &nbsp;TLockWorkStation = function: Boolean;<br>var<br> &nbsp;hUser32: HMODULE;<br> &nbsp;LockWorkStation: TLockWorkStation;<br>begin<br> &nbsp;hUser32 := GetModuleHandle('USER32.DLL');<br> &nbsp;if hUser32 &lt;&gt; 0 then<br> &nbsp;begin<br> &nbsp; &nbsp;@LockWorkStation := GetProcAddress(hUser32, 'LockWorkStation');<br> &nbsp; &nbsp;if @LockWorkStation &lt;&gt; nil then<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;LockWorkStation;<br> &nbsp; &nbsp; &nbsp;Result := True;<br> &nbsp; &nbsp;end;<br> &nbsp;end;<br>end;<br>-----------------------------------------------------------------------------<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>LockWS;<br>end; <br><br><br>响应热键简单,要是只响应热键就很难了,比如:ctrl+alt+del就很难屏蔽掉。
 
谢了!<br>那就不响应热键,能“锁死”键盘和鼠标也行,该怎么实现呢?<br>我希望关闭监视器、锁定系统后,键盘和鼠标都不再响应。
 
上面锁死程序可以简单为:<br>implementation<br>function LockWorkStation:boolean;stdcall;external 'USER32.DLL';<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>LockWorkStation ;<br>end;
 
后退
顶部