Delphi编写的一款锁屏小工具

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.

复制代码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蝈蝈(GuoGuo)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值