本文整理自网络,侵删。
Delphi编写的一款锁屏小工具,双击程序立即锁屏,木有界面的。解除锁屏密码:alt+空格。unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Image1: TImage; Timer2: TTimer; procedure FormCreate(Sender: TObject); procedure Timer2Timer(Sender: TObject); procedure HotKeyDown(var Msg: Tmessage); message WM_HOTKEY; private { Private declarations } public { Public declarations } end;
var Form1: TForm1; FullScreen : Tbitmap; FullScreenCanvas : TCanvas; DC : HDC; HotKeyId: Integer;implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);begin HotKeyId := GlobalAddAtom('MyHotKey') - $C000; RegisterHotKey(Handle, hotkeyid, MOD_ALT, VK_SPACE); FullScreen := Tbitmap.Create; FullScreen.Width := screen.Width; FullScreen.Height := Screen.Height; DC := GetDC(0); FullScreenCanvas := TCanvas.Create; FullScreenCanvas.Handle := DC; FullScreen.Canvas.CopyRect(Rect(0, 0, Screen.Width, Screen.Height), FullScreenCanvas, Rect(0, 0, Screen.Width, Screen.Height)); FullScreenCanvas.Free; ReleaseDC(0, DC); Image1.Picture.Bitmap := FullScreen; image1.Width := FullScreen.Width; Image1.Height := FullScreen.Height; FullScreen.Free; //*****************************************
Form1.Left := 0; Form1.Top := 0; Form1.Width := Screen.Width; Form1.Height := Screen.Height; Image1.Left := 0; Image1.Top := 0;end;
procedure TForm1.Timer2Timer(Sender: TObject);begin SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE + SWP_NOMOVE); //当前窗口置顶end;
procedure TForm1.HotKeyDown(var Msg: Tmessage);begin if (Msg.LparamLo = MOD_ALT) AND (Msg.LParamHi = VK_SPACE) then // 热键为ALT+空格begin Application.Terminate; //窗口结束 UnRegisterHotKey(handle, HotKeyId); //释放热键资源end;end;end.
相关阅读 >>
Delphi三层开发小技巧:tclientdataset的delta妙用
Delphi timage保存图片到stream及从stream中取图片
Delphi2007-Delphi2010 程序不出现在任务栏的方法
更多相关阅读请进入《Delphi》频道 >>