delhi 获取进程图片


本文整理自网络,侵删。

 unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Label1: TLabel;
Label2: TLabel;
Label4: TLabel;
ListBox1: TListBox;
Button5: TButton;
Button6: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function PrintWindow(fh:HWND;hdcBlt:HDC;nFlags:word ):boolean;stdcall;far;external 'user32.dll ';
var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
hwn:hwnd;
begin
hwn:=FindWindow(nil,pchar(edit1.Text));
// hwn:=FindWindow('#32770',nil);
showwindow(hwn,SW_show);
//SendMessage(hwn,WM_Close,0,0); //关闭进程语句
end;

procedure TForm1.Button2Click(Sender: TObject);
var
hwn:hwnd;
begin
hwn:=FindWindow(nil,pchar(edit1.Text));
// hwn:=FindWindow('#32770',nil);
// hwn:=FindWindow(nil,pchar(edit1.Text));
//hwn:=FindWindow(nil,pchar(edit1.Text));
showwindow(hwn,SW_HIDE);
//SendMessage(hwn,WM_Close,0,0); //关闭进程语句
end;

procedure TForm1.Button3Click(Sender: TObject);
var
h: HWND;
ps: array[0..254] of Char;
begin
h := FindWindow(nil, pchar(edit1.Text)); {这句是获取计算器窗口的句柄}

GetClassName(h, ps, 255);
ShowMessage(ps); {SciCalc}
end;


procedure TForm1.Button4Click(Sender: TObject);
var
h: HWnd;
p: array[0..254] of char;
begin
h := GetWindow(Handle, GW_HWNDFIRST);
while h <> 0 do
begin
if GetWindowText(h, p, 255) > 0 then listbox1.items.Add(p);
h := GetWindow(h, GW_HWNDNEXT);
end;

end;
procedure TForm1.FormCreate(Sender: TObject);
var
h: HWnd;
p: array[0..254] of char;
begin
h := GetWindow(Handle, GW_HWNDFIRST);
while h <> 0 do
begin
if GetWindowText(h, p, 255) > 0 then listbox1.items.Add(p);
h := GetWindow(h, GW_HWNDNEXT);
end;

end;

procedure TForm1.ListBox1DblClick(Sender: TObject);
var
i:Integer;
begin
for i :=0 to ListBox1.Count-1 do
begin
if ListBox1.Selected[i] then
edit1.Text:=(ListBox1.Items.Strings[i]);
end;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
SetWindowPos(Handle, HWND_TOPMOST, 200,200, 500,500, SWP_SHOWWINDOW);
end;

procedure TForm1.Button6Click(Sender: TObject);
var
fh:hwnd;
begin
fh:=findwindow(nil,pchar(edit1.Text));
printWindow(fh,image1.Canvas.Handle ,0); //窗口显示,没有最小化和隐藏都可以抓到
//比如 把画图窗口 移出屏幕范围,,也能抓到,,
form1.Repaint ;
end;

end.

相关阅读 >>

Delphi fdmemtable内存表操作

Delphi 如何get/post 调用http请求

Delphi示例代码 android,ios,osx,windows,linux,html5

Delphi firedac 下的 sqlite 创建数据库

Delphi 让程序只运行1次

Delphi 获取指定目录下的所有文件名,包括子目录函数

Delphi 处理图片(剪切,压缩)

Delphi中ocx的动态注册方法

Delphi 组件篇 之 tbevel组件

Delphi 英文单词第一个字母大写

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



打赏

取消

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

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

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

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

评论

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