遍历出Windows当前运行的所有应用程序

时间:2010-01-28 08:41:04  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:essages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, TlHelp32;type ///////////////////////////////    TProcessInfo=RecordExeFile:string;ProcessID:Dword;end;ProcessInfo=^TProcessInfo;//////////typeTForm1 = class(TForm)ListBo...
  正文:请参考如下代码:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, TlHelp32;

type ///////////////////////////////
    TProcessInfo=Record
ExeFile:string;
ProcessID:Dword;
end;
ProcessInfo=^TProcessInfo;//////////


type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var p:ProcessInfo;
ok:Bool;
ProcessListHandle:THandle;
ProcessStruct:TProcessEntry32;
begin
  ProcessListHandle:=CreateToolHelp32Snaphotoshop/ target=_blank class=infotextkey>pshot(TH32cs_SnapProcess,0);
  ProcessStruct.dwSize:=SizeOf(ProcessStruct);
  ok:=Process32First(ProcessListHandle,ProcessStruct);
  while integer(ok)<>0 do
  begin
    New(p);
    p.ExeFile:=ProcessStruct.szExeFile;
    p.ProcessID:=ProcessStruct.th32ProcessID;
    listbox1.Items.Add(p.ExeFile);
    ok:=Process32Next(ProcessListHandle,ProcessStruct);
  end;
  
end;

end.
"遍历出Windows当前运行的所有应用程序"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Language/Delphi/12543.html


关键字:

关于《遍历出Windows当前运行的所有应用程序》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td