J
jomee
Unregistered / Unconfirmed
GUEST, unregistred user!
这段可以正常编译:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
hCurrentWindow : HWnd;
szText : array[0..254] of char;
begin
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255)>0 then
Memo1.Lines.Add(StrPas(@szText));
hCurrentWindow:=GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
end;
我想把她独立成一个函数放在unit2,可是就出错了:
function GetWindowcaption:string;
var
hCurrentWindow : HWnd;
szText : array[0..254] of char;
begin
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);//这里Handie就过不去了,应该怎么办?
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255)>0 then
Result:=StrPas(@szText);
hCurrentWindow:=GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
hCurrentWindow : HWnd;
szText : array[0..254] of char;
begin
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255)>0 then
Memo1.Lines.Add(StrPas(@szText));
hCurrentWindow:=GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
end;
我想把她独立成一个函数放在unit2,可是就出错了:
function GetWindowcaption:string;
var
hCurrentWindow : HWnd;
szText : array[0..254] of char;
begin
hCurrentWindow := GetWindow(Handle, GW_HWNDFIRST);//这里Handie就过不去了,应该怎么办?
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow, @szText, 255)>0 then
Result:=StrPas(@szText);
hCurrentWindow:=GetWindow(hCurrentWindow, GW_HWNDNEXT);
end;
end;