吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3997|回复: 5
收起左侧

[其他转载] 进程枚举

[复制链接]
hixiaosheng 发表于 2010-2-4 17:36
unit Unit1;

interface

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

type
TForm1 = class(TForm)
lst1: TListBox;
tmr1: TTimer;
procedure tmr1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.tmr1Timer(Sender: TObject);
var
prophoto:THandle ;
openpro:ProcessEntry32;
bfirst:Boolean;
begin
lst1.Clear;
prophoto := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
openpro.dwSize := SizeOf(openpro);
bfirst:=Process32First(prophoto,openpro);
while bfirst <> False do
begin
lst1.Items.Add(openpro.szExeFile + ' PID : ' +inttostr(openpro.th32ProcessID));
bfirst:=Process32Next(prophoto,openpro);
end;
CloseHandle(prophoto);

end;

end.

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Squn 发表于 2010-2-4 18:39
来学习~
Squn 发表于 2010-2-4 18:46
关闭快照对象用CloseToolhelp32Snapshot, 我记得别人跟我说用CloseHandle不好...
dwboy 发表于 2010-2-4 20:30
CloseHandle用对地方的话没问题,不过好多时候是在需要句柄的前面关闭掉了,那就爽歪歪了
 楼主| hixiaosheng 发表于 2010-2-4 21:19
代码写的丑,希望姐姐多多关照···
Squn 发表于 2010-2-8 18:17
unit Unit1;

interface

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

type
TForm1 = class(TForm)
lst1: TListBox;
tmr1: TTimer;
procedure tmr1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.tmr1Timer(Sender: TObject);
var
prophoto:THandle ;
openpro:ProcessEntry32;
bfirst:Boolean;
begin
lst1.Clear;
prophoto := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
openpro.dwSize := SizeOf(openpro);
bfirst:=Process32First(prophoto,openpro);
while bfirst <> False do
begin
lst1.Items.Add(openpro.szExeFile + ' PID : ' +inttostr(openpro.th32ProcessID));
bfirst:=Process32Next(prophoto,openpro);
end;
CloseHandle(prophoto);

end;

end.
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-17 04:39

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表