![]() |
IsProcess funktioniert unter Delphi 2010 nicht mehr!
Bekomme bei rProcess.aExeFile, ein blödsinn Raus!
Unter Delphi 2007 funktioniert es noch! Betriebsystem WinXP!
Delphi-Quellcode:
Hat wer eine Idee?
function IsProcess(ExeName: string): Boolean;
(* ** This routine examines Windows processes currently running to see if a ** certain program is running. ** ** sExe : The executable name of the program to check. ** Result: True if the program is running, False otherwise. *) var liI, lSnapShot: Longint; rProcess : TProcessEntry32; begin Result := False; ExeName := UpperCase(ExeName); lSnapShot := CreateToolHelpSnapShot(TH32CS_SNAPPROCESS, 0); if lSnapShot <> 0 then begin rProcess.iSize := SizeOf(rProcess); liI := ProcessFirst(lSnapShot, rProcess); while liI <> 0 do begin if Pos(ExeName, UpperCase(rProcess.aExeFile)) <> 0 then begin Result := True; Break; end; liI := ProcessNext(lSnapShot, rProcess); end; CloseHandle(lSnapShot); end; end; |
AW: IsProcess funktioniert unter Delphi 2010 nicht mehr!
Welchen Typ hat ExeName?
|
AW: IsProcess funktioniert unter Delphi 2010 nicht mehr!
Zitat:
|
AW: IsProcess funktioniert unter Delphi 2010 nicht mehr!
Nimm AnsiString
|
AW: IsProcess funktioniert unter Delphi 2010 nicht mehr!
was ist "blödsinn"?
|
AW: IsProcess funktioniert unter Delphi 2010 nicht mehr!
Delphi-Quellcode:
1. Was hat meine Variable ExeName damit zu tun? Ich spreche ja von rProcess.aExeName!
type
TProcessEntry32 = packed record iSize, iUsage, iProcessID, iDefaultHeapId, iModuleId, iThreads, iParentProcessId, iPriClassBase, iFlags : Integer; aExeFile: array[0..MAX_PATH] of Char; end; function CreateToolHelpSnapShot(lFlags, lProcessId: Longint): Longint; stdcall; function ProcessFirst(hSnapshot: longint; var uProcess: TProcessEntry32): Longint; stdcall; function ProcessNext(hSnapshot: Longint; var uProcess: TProcessEntry32): Longint; stdcall; procedure CloseHandle(hPass: Longint); StdCall; 2. Sowas kommt z.b.: Viereck(Symbol meine ich), Viereck, Viereck, Viereck, . e x e, usw. |
AW: IsProcess funktioniert unter Delphi 2010 nicht mehr!
Ich würde mal mkinzlers Beitrag 4 zustimmen.
vorallem wenn man eingene Deklarationen/Implementationen von etwas verwendet, dann sollte man schonmal aufpassen, daß auch die Richtigen APIs implentiert werden und dieses auch noch richtig, damit der Compiler notfalls auch mal Fehlermeldungen bezüglich AnsiChar<>Char<>WideChar ausgeben kann (gibt unterschiedliche APIs für Ansi und Unicode)
Delphi-Quellcode:
PS: Nur den Dateinamen zu prüfen ist nicht nicht sicher, da man auch gleichnamige Programme aus unterschiedlichen Verzeichnis starten kann,
function ProcessIsRunning(ExeName: string): Boolean;
(* ** This routine examines Windows processes currently running to see if a ** certain program is running. ** ** sExe : The executable name of the program to check. ** Result: True if the program is running, False otherwise. *) var liI, lSnapShot: Longint; rProcess : TProcessEntry32; begin Result := False; ExeName := ExtractFileName(ExeName); lSnapShot := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if lSnapShot <> 0 then try rProcess.dwSize := SizeOf(rProcess); if Process32First(lSnapShot, rProcess) then repeat if AnsiSameText(ExeName, rProcess.szExeFile) then begin Result := True; Exit; end; until not Process32Next(lSnapShot, rProcess); finally CloseHandle(lSnapShot); end; end; oder versuch es inkl. der kompletten Pfade: Was willst du denn damit erreichen? eventuell ist ![]() |
AW: IsProcess funktioniert unter Delphi 2010 nicht mehr!
Ok, jetzt funktionierts mit ProcessIsRunning!
Den Rest kann ich kicken jetzt! Danke! Scheinbar wer der SourceCode zu alt! |
AW: IsProcess funktioniert unter Delphi 2010 nicht mehr!
Problem gelöst
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:42 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz