- UID
- 31191
注册时间2007-5-1
阅读权限20
最后登录1970-1-1
以武会友
 
TA的每日心情 | 开心 2024-6-9 16:20 |
---|
签到天数: 24 天 [LV.4]偶尔看看III
|
发表于 2008-1-10 22:22:44
|
显示全部楼层
首先打开 计算器 再运行程序
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
yf:THandle ; //声明
a:Integer;
b:pchar ;
begin
yf:=FindWindow(nil,'计算器') ; //找计算器
if yf<>0 then
begin
showmessage('发现目标') ;
a:=GetWindowTextLength(yf); //得到标题长度
if a<>0 then
begin
ShowMessage('得到长度'+inttostr(a)) ;
GetWindowText(yf,b,a+1) ;
ShowMessage(b);//为何返回总是空值
end
end
end;
end. |
|