Autor Beitrag
seddto
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: Do 06.05.04 17:44 
Hallo,

Ich möchte gerne festellen ob ein bestimmter Prozess läuft. Ich hab mir schon verschiedene Threads hier zu diesem Thema durchgelesen, zb. über Enumwindows. Allerdings wurde das problem dort immer über die Suche nach einem bestimmten String im Fenstertitel gesucht. Das funktioniert bei meinem Problem leider nicht weil ich wie gesagt, weil ich die laufenden Prozess nach einem bestimmten Exe-Namen durchsuchen möchte. Ich hab auch schon versucht die Fenster-Class herauszubekommen, das funktioniert allerdings auch nicht, weil das entsprechende Programm eine Konsolenanwendung ist. Außerdem kommen, wenn ich mit Enumwindows die aktiven Fenster durchlaufe unter getwindowclass immer nur ganz abstrackte Bezeichnungen, nach denen ich nicht darauf schliessen kann, welches Programm dahinter steckt. Weiss jemand wie ich mit enumwindows oder einer anderen Funktion die laufenden Prozesse nach einem Exe-Namen durchsuchen kann?
Wäre echt dankbar für ein bisschen Hilfe :)

LG Seddto.
bms
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 735

Win XP
Delphi 3, Delphi 6 PE, Delphi 2005 PE
BeitragVerfasst: Do 06.05.04 19:05 
Welches System?

_________________
VORSICHT: Ich behersche seit heute die Fünf-Finger-Handflächen-Herz-Explodier-Schlag-Kampf-Technik >:(
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 06.05.04 20:59 
Suche in: Delphi-Forum, Delphi-Library SNAPSHOT - funzt unter allen OS außer NT 4.0

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Do 06.05.04 22:18 
Statt Suche, sollten

Zitat:
Takes a snapshot of the processes and the heaps, modules, and threads used by the processes.

HANDLE WINAPI CreateToolhelp32Snapshot(DWORD dwFlags,
DWORD th32ProcessID);


Parameters

dwFlags

Flags specifying portions of the system to include in the snapshot. These values are defined:

TH32CS_INHERIT Indicates that the snapshot handle is to be inheritable.
TH32CS_SNAPALL Equivalent to specifying the TH32CS_SNAPHEAPLIST, TH32CS_SNAPMODULE, TH32CS_SNAPPROCESS, and TH32CS_SNAPTHREAD values.
TH32CS_SNAPHEAPLIST Includes the heap list of the specified process in the snapshot.
TH32CS_SNAPMODULE Includes the module list of the specified process in the snapshot.
TH32CS_SNAPPROCESS Includes the Win32 process list in the snapshot.
TH32CS_SNAPTHREAD Includes the Win32 thread list in the snapshot.

th32ProcessID
Process identifier. This parameter can be zero to indicate the current process. This parameter is used when the TH32CS_SNAPHEAPLIST or TH32CS_SNAPMODULE value is specified. Otherwise, it is ignored.

Return Value
Returns an open handle to the specified snapshot if successful or - 1 otherwise.


Zitat:

BOOL WINAPI Process32First(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);

Parameters
hSnapshot
Handle of the snapshot returned from a previous call to the CreateToolhelp32Snapshot function.

lppe
Address of a PROCESSENTRY32 structure.

Return Value
Returns TRUE if the first entry of the process list has been copied to the buffer or FALSE otherwise. The ERROR_NO_MORE_FILES error value is returned by the GetLastError function if no processes exist or the snapshot does not contain process information.


und
Zitat:
BOOL WINAPI Process32Next(HANDLE hSnapshot, LPPROCESSENTRY32 lppe);

Parameters
hSnapshot
Handle of the snapshot returned from a previous call to the CreateToolhelp32Snapshot function.
lppe
Address of a PROCESSENTRY32 structure.
Return Value
Returns TRUE if the next entry of the process list has been copied to the buffer or FALSE otherwise. The ERROR_NO_MORE_FILES error value is returned by the GetLastError function if no processes exist or the snapshot does not contain process information.



Zitat:

typedef struct tagPROCESSENTRY32 {
DWORD dwSize;
DWORD cntUsage;
DWORD th32ProcessID;
DWORD th32DefaultHeapID;
DWORD th32ModuleID;
DWORD cntThreads;
DWORD th32ParentProcessID;
LONG pcPriClassBase;
DWORD dwFlags;
char szExeFile[MAX_PATH];
} PROCESSENTRY32;
typedef PROCESSENTRY32 * PPROCESSENTRY32;
typedef PROCESSENTRY32 * LPPROCESSENTRY32;


(aus W32 SDK)
das richtige sein.

grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 06.05.04 22:25 
Und die Suche führt auch gleich zu ein paar hilfreichen Code-Schnipsel wie man genau diese Funktionen verwendet..! ;)

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
scrooge
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 200



BeitragVerfasst: Fr 07.05.04 15:24 
Um das ganze etwas sicherer u machen (es könnten schließlich mehere Exe mit selben NAme laufen) könntest du auch noch GetModuleFilenameEx aus der psApi holen.
Shadow110
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Fr 07.05.04 16:10 
Wir sind zwar im Windows API Forum... aber vielleicht ist es ja trotdem interessant..
Madcollection installieren

www.madshi.net

Und dann

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  antwort:boolean;
begin
  antwort := Process('calc.exe').IsStillRunning;
end;


Grüße
Alex

Moderiert von user profile iconPeter Lustig (16:10, 07.05.2004): Delphi-Tags hinzugefügt