delphi 简单的截图代码


本文整理自网络,侵删。

 program JieTug;

{$APPTYPE CONSOLE}

uses
Windows,
Graphics,
Jpeg;

function PrintWindow(SourceWindow: hwnd; Destination: hdc; nFlags: cardinal): bool; stdcall; external 'user32.dll' name 'PrintWindow';

procedure JieTu(); stdcall;
var
bmp : TBitmap;
wnd : cardinal;
Jpg:Tjpegimage;
rec : TRect;
begin
wnd := FindWindow(nil,'计算器');
if wnd <> 0 then
begin
GetWindowRect(wnd,rec);
bmp := TBitmap.Create;//??建一??BITMAP?泶娣?D像
Jpg:=Tjpegimage.Create;//??建一??jpeg?泶娣?D像
try
bmp.Width := rec.Right - rec.Left; //创建高宽
bmp.Height := rec.Bottom - rec.Top;//创建高宽
PrintWindow(wnd, bmp.Canvas.Handle, 0);//
Jpg.Assign (bmp);//复制抓到的屏幕
Jpg.SaveToFile('1.jpg');//保存地址
bmp.Free;
Jpg.Free;
finally
end; //////这个代码EXE200多K 能不能变小点
end;
end;
begin
JieTu;
end.

相关阅读 >>

md5.pas

Delphi截取字符串 防止中文截断

Delphi xe3里判断网络是否连接成功

Delphi中messagebox用法

Delphi 2009 indy10 idhttp get 中文出现乱码的问题

Delphi生成32位随机数

Delphi isipadress 非正则表达式验证ip的方法

Delphi中控制与捕捉输入法的实现单元

Delphi tbitmap创建时提示object or class type required

Delphi 模拟网站验证码

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



打赏

取消

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

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

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

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

评论

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