var
szText: array[0..254] of char;
hCurrentWindow :hwnd;
begin
hCurrentWindow := GetWindow(Handle,GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if GetWindowText(hCurrentWindow ,@szText,255) > 0 then
if pos('H3C', StrPas(@szText))<>0 then //这里指定某一窗口,可能有多个
begin
memo1.lines.Add(StrPas(@szText)); //窗口名称全称
memo1.lines.Add(IntToStr(hCurrentWindow)); //句柄
end;
hCurrentWindow := GetWindow(hCurrentWindow,GW_HWNDNEXT);
end;
StrPas(@szText) //窗口名称全称
IntToStr(hCurrentWindow); //句柄
=====================
//获取所有窗体名称
procedure TForm1.btn1Click(Sender: TObject);
var
szText: array[0..254] of char;
hCurrentWindow :hwnd;
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;