如何监控程序运行的列表,即知道当前计算机运行了那些程序,这些程序的文件名以及对应的磁盘文件。
解决方案 »
- DBGridEhDrawColumnCell 方法取数值????
- 新手问题
- 用SetwindowPos将一个窗口HWND_TOPMOST之后怎么变成正常(不是最前的)的窗口啊?
- 帮忙看一下交叉表的存储过程错在哪!
- 怎么在EXCEL中进行查找?
- 【delphi+oracle报表解决方案(二)】临时表的使用
- 急!请问如何将ADOQuery返回的记录集,另存成一个Excel文件(原来并不存在,是新建立的。),并且在第二个工作表里显示这个记录集?谢谢
- b/s多层应用的初级问题,请来看看。
- delphi中如何把一个excel文件中的数据拷贝到另一个excel文件中??
- 如何用资源文件re?
- ★★★软件测试,欢迎帮忙,绝对给分!★★★
- 基于TCustomControl之上开发的组件如何获得焦点。谢谢。
ProcessSnapShotHandle: THandle;
ProcessEntry: TProcessEntry32;
ProcessHandle: THandle;
Ret: BOOL;
s: string;
Position: Byte; ModuleSnapShotHandle: THandle;
ModuleEntry: TModuleEntry32;
begin
ProcessSnapShotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if ProcessSnapShotHandle>0 then
begin
ProcessEntry.dwSize:=SizeOf(TProcessEntry32);
Ret:=Process32First(ProcessSnapShotHandle, ProcessEntry);
while Ret do
begin
ModuleSnapShotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessEntry.th32ProcessID);
if ModuleSnapShotHandle>0 then
begin
ModuleEntry.dwSize:=SizeOf(TModuleEntry32);
Ret:=Module32First(ModuleSnapShotHandle, ModuleEntry);
if Ret then
begin
s:=ModuleEntry.szExePath;
CloseHandle(ModuleSnapShotHandle)
end;
Ret:=Process32Next(ProcessSnapShotHandle, ProcessEntry)
end;
CloseHandle(ProcessSnapShotHandle);
end
end;
s里就是你要的了.
{$R *.dfm}
procedure SearchProcess(T:Tstrings);
var lppe: TProcessEntry32;
found : boolean;
Hand : THandle;
begin
Hand := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
Found:=false;
while not found do
found := Process32First(Hand,lppe);
T.Clear;
while found do
begin
T.Add(copy(inttostr(lppe.th32ProcessID)+' ',1,15)
+StrPas(lppe.szExeFile));//列出所有进程。
found := Process32Next(Hand,lppe);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SearchProcess(memo1.Lines)
end