ShellApi 列举正在运行的程序

//列举正在运行的程序 
uses ShellApi;


{在interface下面type上面输入}
const MY_MESSAGE = WM_USER + 100;


procedure TForm1.Button1Click(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;




posted @ 2012-06-03 17:55  XE2011  阅读(128)  评论(0编辑  收藏  举报