procedure TForm1.Button1Click(Sender: TObject);<br>var ///////得到运行程序////////////<br> hCurrentWindow: HWnd;<br> szTEXt: array[0..254] of Char;<br>begin<br> hCurrentWindow := Getwindow(Handle, GW_HWNDFIRST);<br> while hCurrentWindow <> 0 do begin<br> if GetwindowText(hCurrentWindow, @szTEXt, 255) > 0 then begin<br> Memo1.Lines.Add(strpas(@szTEXt));<br> Memo1.Lines.Add(inttostr(getWindowThreadProcessId(hCurrentWindow, nil)));<br> end;<br> hCurrentWindow := Getwindow(hCurrentWindow, GW_HWNDNEXT);<br> end;<br>end;