谁有空看看 代码不长( 取进程路径,出了点意外,部分进程失败 ) ( 积分: 50 )

  • 主题发起人 主题发起人 全文检索
  • 开始时间 开始时间

全文检索

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

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

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

var
Form1: TForm1;

implementation

{$R *.dfm}
//´Ó½ø³ÌIDµÃµ½½ø³ÌµÄ·¾¶
function GetModulesofProcess(const ProcessID: DWORD): String;
var
lpme: TModuleEntry32;
SsHandle: THandle;
FoundAProc: Boolean;
begin
lpme.dwSize := SizeOf(lpme);

ssHandle := CreateToolHelp32SnapShot(TH32CS_SNAPMODULE, ProcessID);
FoundAProc := Module32First(SsHandle, lpme);

if FoundAProc then
begin
Result := lpme.szExePath;
end
else Result := 'ʧ°Ü';
CloseHandle(SsHandle);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
lppe: tprocessentry32;
sshandle: thandle;
hh: hwnd;
found: boolean;
i:integer;
filename:string;
begin
sshandle := createtoolhelp32snapshot(TH32CS_SNAPPROCESS, 0);
lppe.dwSize := SizeOf(tprocessentry32);
found := process32first(sshandle, lppe);
while found do
begin
filename:=(lppe.szExeFile);
ListBox1.Items.Add(filename);
ListBox1.Items.Add(GetModulesofProcess(lppe.th32ProcessID));
found := process32next(sshandle, lppe);
end;
CloseHandle(sshandle);
end;

end.


出来的效果是这样的

[System Process]
C:/列举所有进程的EXE文件名/Project1.exe
System
失败
SMSS.EXE
失败
CSRSS.EXE
失败
WINLOGON.EXE
失败
SERVICES.EXE
失败
LSASS.EXE
失败
SVCHOST.EXE
失败
SVCHOST.EXE
失败
PAVSRV51.EXE
失败
AVENGINE.EXE
失败
SVCHOST.EXE
失败
SVCHOST.EXE
失败
SVCHOST.EXE
失败
SPOOLSV.EXE
失败
SCARDSVR.EXE
失败
SOUNDMAN.EXE
C:/WINDOWS/SOUNDMAN.EXE
RUNDLL32.EXE
C:/WINDOWS/system32/RUNDLL32.EXE
SafeSignCertReg.exe
C:/WINDOWS/system32/SafeSignCertReg.exe
Vm_sti.exe
C:/WINDOWS/VM_STI.EXE
EAZTRAY.EXE
C:/Program Files/Yuguo/EAZTray.exe
ApVxdWin.exe
C:/Program Files/熊猫/熊猫卫士防病毒2007/APVXDWIN.EXE
CTFMON.EXE
C:/WINDOWS/system32/ctfmon.exe
EAZClnt.exe
失败
nvsvc32.exe
失败
PsImSvc.exe
失败
shdserv.exe
失败
SVCHOST.EXE
失败
alg.exe
失败
WebProxy.exe
c:/program files/熊猫/熊猫卫士防病毒2007/WebProxy.exe
wscntfy.exe
C:/WINDOWS/system32/wscntfy.exe
QQ.EXE
D:/Program Files/Tencent/QQ/QQ.exe
TIMPlatform.exe
F:/Program Files/Tencent/QQ/TIMPlatform.exe
DELPHI32.EXE
C:/Program Files/Borland/Delphi7/Bin/delphi32.exe
conime.exe
C:/WINDOWS/system32/conime.exe
EXPLORER.EXE
C:/WINDOWS/explorer.exe
TTraveler.exe
C:/Program Files/Tencent/TT/TTraveler.exe
Project1.exe
C:/列举所有进程的EXE文件名/Project1.exe
 
N多的进程无法获得路径
 
我的机子上可是都列出来了

////////////////////////////////////////
[System Process]
'C:/Program Files/Borland/Delphi7/Projects/Project1.exe
System
'失败
smss.exe
'/SystemRoot/System32/smss.exe
csrss.exe
'/??/C:/WINDOWS/system32/csrss.exe
winlogon.exe
'/??/C:/WINDOWS/system32/winlogon.exe
services.exe
'C:/WINDOWS/system32/services.exe
lsass.exe
'C:/WINDOWS/system32/lsass.exe
svchost.exe
'C:/WINDOWS/system32/svchost.exe
svchost.exe
'C:/WINDOWS/system32/svchost.exe
svchost.exe
'C:/WINDOWS/System32/svchost.exe
svchost.exe
'C:/WINDOWS/system32/svchost.exe
svchost.exe
'C:/WINDOWS/system32/svchost.exe
rfwsrv.exe
'e:/瑞星/rising/rfw/rfwsrv.exe
spoolsv.exe
'C:/WINDOWS/system32/spoolsv.exe
msdtc.exe
'C:/WINDOWS/system32/msdtc.exe
explorer.exe
'C:/WINDOWS/Explorer.EXE
Apache.exe
'D:/Apache+PHP+MySQL/Apache/Apache2/bin/Apache.exe
RFWMAIN.EXE
'e:/瑞星/rising/rfw/RfwMain.exe
sqlservr.exe
'C:/PROGRA~1/MICROS~4/MSSQL/binn/sqlservr.exe
rundll32.exe
'C:/WINDOWS/system32/Rundll32.exe
mysqld-nt.exe
'D:/Apache+PHP+MySQL/MySQL/bin/mysqld-nt.exe
nvsvc32.exe
'C:/WINDOWS/system32/nvsvc32.exe
Apache.exe
'D:/Apache+PHP+MySQL/Apache/Apache2/bin/Apache.exe
mqsvc.exe
'C:/WINDOWS/system32/mqsvc.exe
mqtgsvc.exe
'C:/WINDOWS/system32/mqtgsvc.exe
realsched.exe
'C:/Program Files/Common Files/Real/Update_OB/realsched.exe
ctfmon.exe
'C:/WINDOWS/system32/ctfmon.exe
ApacheMonitor.exe
'D:/Apache+PHP+MySQL/Apache/Apache2/bin/ApacheMonitor.exe
VnetClient.exe
'C:/Program Files/ChinaNet/VnetClient.exe
alg.exe
'C:/WINDOWS/System32/alg.exe
conime.exe
'C:/WINDOWS/system32/conime.exe
rnathchk.exe
'C:/Program Files/Common Files/Real/Update_OB/rnathchk.exe
IEXPLORE.EXE
'C:/Program Files/Internet Explorer/iexplore.exe
delphi32.exe
'C:/Program Files/Borland/Delphi7/Bin/delphi32.exe
winhlp32.exe
'C:/WINDOWS/winhlp32.exe
XDICT.EXE
'C:/Program Files/XDict/XDICT.EXE
Project1.exe
'C:/Program Files/Borland/Delphi7/Projects/Project1.exe
 
需要SeDebugPrivilege权限才行,调权的代码在坛子上有很多了,就不多说了.
 
问题没有得到解决

我的账户就是运行在计算机管理员的级别上,也没有添加其它账户
 
多人接受答案了。
 
后退
顶部