delphi 查看windows后台进程是否运行

function TfmLogin.FindProcess(AFileName: string): boolean;
var
  hSnapshot : THandle;
  lppe : TProcessEntry32;
  Found : Boolean;
begin
  Result := False;
  hSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  lppe.dwSize := SizeOf(TProcessEntry32);
  Found := Process32First(hSnapshot, lppe);
  while Found do
  begin
    if ((UpperCase(ExtractFileName(lppe.szExeFile))=UpperCase(AFileName)) or (UpperCase(lppe.szExeFile )=UpperCase(AFileName))) then
    begin
      Result := True;
    end;
      Found := Process32Next(hSnapshot, lppe);
  end;

end;


  if not FindProcess('ScktSrvr.exe') then
  begin
      ShowMessage('scktsrvr.exe未启用!');
      exit;
  end;

猜你喜欢

转载自blog.csdn.net/qin_yaping/article/details/77856175
今日推荐