Delphi checks whether the windows background process is running

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;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325495108&siteId=291194637