dephi winspy Demo
在spy+中未找到这样的功能
有个隐藏窗口的进程,相让窗口显示出来,虽然可以找到进程ID,然后再逐步找到主窗口句柄,但又没句柄发各种消息的软件。
计得以前有个窗口精灵之类的,网上找了很多,要么没有此功能,甚至一个小功能都了注册,收费。
得,自己直接整一个,根据进程ID找到进程的主窗口句柄,然后可以根据句柄,可以控制窗体的显示与隐藏。
1 unit uFrmWin; 2 3 interface 4 5 uses 6 Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, 7 System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, 8 Vcl.StdCtrls, uWinUtils, Vcl.ExtCtrls; 9 10 type 11 TfrmWin = class(TForm) 12 edtWinHandle: TEdit; 13 lblWinHandle: TLabel; 14 ckbHex: TCheckBox; 15 btnShowWindow: TButton; 16 btnHideWindow: TButton; 17 edtTranHandle: TEdit; 18 btnGetHandleByPID: TButton; 19 edtPID: TEdit; 20 Label1: TLabel; 21 Panel1: TPanel; 22 Panel2: TPanel; 23 btnShowAndFront: TButton; 24 procedure FormShow(Sender: TObject); 25 procedure btnShowWindowClick(Sender: TObject); 26 procedure edtWinHandleChange(Sender: TObject); 27 procedure ckbHexClick(Sender: TObject); 28 procedure btnHideWindowClick(Sender: TObject); 29 procedure btnGetHandleByPIDClick(Sender: TObject); 30 procedure btnShowAndFrontClick(Sender: TObject); 31 private 32 procedure DoTransfor(); 33 public 34 { Public declarations } 35 end; 36 37 var 38 frmWin: TfrmWin; 39 40 implementation 41 42 {$R *.dfm} 43 44 procedure TfrmWin.btnHideWindowClick(Sender: TObject); 45 var 46 hHandle: THandle; 47 sHandle: string; 48 begin 49 sHandle := edtTranHandle.Text; 50 hHandle := StrToIntDef(sHandle, 0); 51 ShowWindow(hHandle, SW_HIDE); 52 end; 53 54 procedure TfrmWin.btnShowAndFrontClick(Sender: TObject); 55 var 56 hHandle: THandle; 57 sHandle: string; 58 begin 59 sHandle := edtTranHandle.Text; 60 hHandle := StrToIntDef(sHandle, 0); 61 BringToFrontByHandle(hHandle); 62 end; 63 64 procedure TfrmWin.btnShowWindowClick(Sender: TObject); 65 var 66 hHandle: THandle; 67 sHandle: string; 68 begin 69 sHandle := edtTranHandle.Text; 70 hHandle := StrToIntDef(sHandle, 0); 71 ShowWindow(hHandle, SW_SHOW); 72 end; 73 74 procedure TfrmWin.btnGetHandleByPIDClick(Sender: TObject); 75 var 76 pid: Integer; 77 hHandle:THandle; 78 begin 79 pid := StrToIntDef(edtPID.Text, 0); 80 hHandle:= GetHwndFromProcess(pid); 81 ckbHex.Checked:=False; 82 edtWinHandle.Text:=hHandle.ToString(); 83 end; 84 85 procedure TfrmWin.ckbHexClick(Sender: TObject); 86 begin 87 DoTransfor(); 88 end; 89 90 procedure TfrmWin.edtWinHandleChange(Sender: TObject); 91 begin 92 DoTransfor(); 93 end; 94 95 procedure TfrmWin.DoTransfor; 96 var 97 sHandle: string; 98 begin 99 sHandle := edtWinHandle.Text; 100 if ckbHex.Checked then 101 begin 102 edtTranHandle.Text := StrToIntDef('$' + sHandle, 0).ToString(); 103 end 104 else 105 begin 106 edtTranHandle.Text := StrToIntDef(sHandle, 0).ToString(); 107 end; 108 end; 109 110 procedure TfrmWin.FormShow(Sender: TObject); 111 begin 112 if edtWinHandle.CanFocus then 113 edtWinHandle.SetFocus; 114 end; 115 116 end.
uWinUtils.pas单元摘要
欢迎微信搜一搜 IT软件部落 关注公众号,你可以了解更详细的内容
欢儿微信扫码关注 IT软件部落 公众号,你可以了解更详细的内容
posted on 2024-07-03 23:33 bluejade2024 阅读(6) 评论(0) 编辑 收藏 举报