展开全部
定义一个全局变量
var
handlelist: tstringlist;
procedure TForm1.Button1Click(Sender: TObject);
function GetProcessExePath(h: HWND): BOOL; stdcall;
function getfilename(str: string): string;
begin
result := UpperCase(ExtractFileName(str));
end;
var
pid: Cardinal;
pHandle: THandle;
buf: array[0..MAX_PATH] of Char;
str: string;
begin
GetWindowThreadProcessId(h, @pid);
pHandle := OpenProcess(PROCESS_ALL_ACCESS, False, pid);
GetModuleFileNameEx(pHandle, 0, buf, Length(buf));
CloseHandle(pHandle);
str := StrPas(buf);
handlelist.Add(IntTostr(h)+str);//句柄加文件路径
Result := True;
end;
var
i: integer;
begin
if form1.OpenDialog1.Execute then
begin
Edit1.Text := OpenDialog1.FileName;
EnumWindows(@getprocessexepath, 0);
for i := 0 to handlelist.count - 1 do
listbox1.items.add(handlelist.string[i]);
end;
end;
var
handlelist: tstringlist;
procedure TForm1.Button1Click(Sender: TObject);
function GetProcessExePath(h: HWND): BOOL; stdcall;
function getfilename(str: string): string;
begin
result := UpperCase(ExtractFileName(str));
end;
var
pid: Cardinal;
pHandle: THandle;
buf: array[0..MAX_PATH] of Char;
str: string;
begin
GetWindowThreadProcessId(h, @pid);
pHandle := OpenProcess(PROCESS_ALL_ACCESS, False, pid);
GetModuleFileNameEx(pHandle, 0, buf, Length(buf));
CloseHandle(pHandle);
str := StrPas(buf);
handlelist.Add(IntTostr(h)+str);//句柄加文件路径
Result := True;
end;
var
i: integer;
begin
if form1.OpenDialog1.Execute then
begin
Edit1.Text := OpenDialog1.FileName;
EnumWindows(@getprocessexepath, 0);
for i := 0 to handlelist.count - 1 do
listbox1.items.add(handlelist.string[i]);
end;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询