如何编写检测特定Exe文件是否正在运行的查询函数?
- 内容介绍
- 文章标签
- 相关推荐
本文共计167个文字,预计阅读时间需要1分钟。
cfunction exeIsRunning(exeName: String): Boolean { var hCurrentWindow: HWnd; var szText: array[0..254] of char; var result: Boolean=False; hCurrentWindow=GetWindow(Application.Handle, GW_HWNDFIRST); while (hCurrentWindow 0) { GetWindowText(hCurrentWindow, szText, 254); if (CompareText(szText, exeName)=0) { result=True; break; } hCurrentWindow=GetWindow(hCurrentWindow, GW_HWNDNEXT); } return result;}
var
hCurrentWindow:HWnd;
szText:array[0..254] of char;
begin
Result := False;
hCurrentWindow:=Getwindow(Application.Handle,GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if Getwindowtext(hCurrentWindow,@sztext,255)>0 then
begin
if LowerCase(pchar(@sztext))=LowerCase(exeName) then
begin
Result := true;
Exit;
end;
end;
hCurrentWindow:=Getwindow(hCurrentwindow,GW_HWndNext);
end;
end;
用法:
如我们要判断'ScktSrvr.exe'程序是否正在运行/是否已经启动
if exe_is_running('ScktSrvr') then
....
else
本文共计167个文字,预计阅读时间需要1分钟。
cfunction exeIsRunning(exeName: String): Boolean { var hCurrentWindow: HWnd; var szText: array[0..254] of char; var result: Boolean=False; hCurrentWindow=GetWindow(Application.Handle, GW_HWNDFIRST); while (hCurrentWindow 0) { GetWindowText(hCurrentWindow, szText, 254); if (CompareText(szText, exeName)=0) { result=True; break; } hCurrentWindow=GetWindow(hCurrentWindow, GW_HWNDNEXT); } return result;}
var
hCurrentWindow:HWnd;
szText:array[0..254] of char;
begin
Result := False;
hCurrentWindow:=Getwindow(Application.Handle,GW_HWNDFIRST);
while hCurrentWindow <> 0 do
begin
if Getwindowtext(hCurrentWindow,@sztext,255)>0 then
begin
if LowerCase(pchar(@sztext))=LowerCase(exeName) then
begin
Result := true;
Exit;
end;
end;
hCurrentWindow:=Getwindow(hCurrentwindow,GW_HWndNext);
end;
end;
用法:
如我们要判断'ScktSrvr.exe'程序是否正在运行/是否已经启动
if exe_is_running('ScktSrvr') then
....
else

