delphi截图程序无窗口版


本文整理自网络,侵删。

 program ScreenShot;

uses Windows, Classes, Graphics, Jpeg;

procedure DrawCursor(Bmp: TBitmap);
var
  r: TRect;
  CI: TCursorInfo;
  Icon: TIcon;
  II: TIconInfo;
begin
  r := Bmp.Canvas.ClipRect;
  Icon := TIcon.Create;
  try
    CI.cbSize := SizeOf(CI);
    if GetCursorInfo(CI) then
      if CI.Flags = CURSOR_SHOWING then
      begin
        Icon.Handle := CopyIcon(CI.hCursor);
        if GetIconInfo(Icon.Handle, II) then
        begin
          Bmp.Canvas.Draw(
            ci.ptScreenPos.x - Integer(II.xHotspot) - r.Left,
            ci.ptScreenPos.y - Integer(II.yHotspot) - r.Top,
            Icon
            );
        end;
      end;
  finally
    Icon.Free;
  end;
end;

procedure SaveScreenToFile(FileName: String);
var
  Bmp: TBitmap;
  Jpg: TJpegImage;
begin
  Bmp := TBitmap.Create;
  Jpg := TJpegImage.Create;
  try
    Bmp.Width := GetSystemMetrics(SM_CXSCREEN);
    Bmp.Height := GetSystemMetrics(SM_CYSCREEN);
    BitBlt(Bmp.Canvas.Handle, 0, 0, Bmp.Width, Bmp.Height, GetDc(0), 0, 0, SRCCOPY);
    DrawCursor(Bmp);
    Jpg.Assign(Bmp);
    Jpg.CompressionQuality := 60;
    Jpg.Compress;
    Jpg.SaveToFile(FileName);
  finally
    Bmp.free;
    Jpg.free;
  end;
end;

begin
 SaveScreenToFile('SHOT.JPG');
end.

相关阅读 >>

Delphi 强迫将半型英数字转换成全型英数字

Delphi 实现检测线程类tthread是否结束

Delphi 清空某个form的控件内容,用tag来判断

Delphi 10.3 断点全部失效

Delphi用代码实现注册ocx和dll

Delphixe5如何获取android手机sim卡串号

Delphi为你的窗体有效地提供剪贴板的相关操作

Delphi xe实现android 添加图片资源到应用并使用它

Delphi 学习 sql 语句 - select(9): 其他

Delphi 检查父进程

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...