本文整理自网络,侵删。
Delphi 取最前窗口标题(不重复)
memo1.Align:=alClient;
procedure TForm1.Timer1Timer(Sender: TObject);
var
p:pchar;
itemp:integer;
begin
p:=allocmem(255);
itemp:=GetForegroundWindow;
GetWindowText(itemp,p,255);
if (p<>'') then
begin
if Pos(p,Memo1.Text)=0 then //不重复,则添加,已有重复的不再添加到memo中
Memo1.Lines.Add(p) ;
end;
freemem(p,255);
end;
相关阅读 >>
Delphi winapi: getmodulefilename、getmodulehandle
Delphi 将 html 代码直接加入到 twebbrowser 组件中去
用Delphi通过setupapi.dll列举和停用硬件设备
更多相关阅读请进入《Delphi》频道 >>