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 怎么将一个流转换成字符串?或者将字符串转出一个流

Delphi调用外部程序并等待其运行结束

Delphi 显示选择文件夹对话框 (有新建按钮)

Delphi中实现dll文件自动注册

Delphi 创建大窗口

Delphi windows 底下根据一个进程的名字杀死一个进程的代码

Delphi xe7实现手机上获取wifi信息的程序

Delphi 按esc快捷键退出程序的简单方法

Delphi xe10 android 界面设计-个人心得

Delphi 一组数据,按由大到小进行排序,并输出最大值与最小值

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



打赏

取消

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

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

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

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

评论

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

    暂无评论...