Hallo Robert!
Auf ins 4te-Mal. Ich habe ganze 15 Minuten gebraucht, bis ich endlich dein Problem, so glaube ich, an der Nase gepackt habe! Du kannst die Funktion CreateProcess
BOOL CreateProcess(
LPCTSTR lpApplicationName,
// pointer to name of executable module
LPTSTR lpCommandLine, // pointer to command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // process security attributes
LPSECURITY_ATTRIBUTES lpThreadAttributes, // thread security attributes
BOOL bInheritHandles, // handle inheritance flag
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // pointer to new environment block
LPCTSTR lpCurrentDirectory, // pointer to current directory name
LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO
LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION
);
ja eh wie WinExec (hat eigentlich Ralf Klaus schon geschrieben) verwenden. In dieser Funktion wird der Identifier des Process über die Übergabeparameter zurückgegeben:
MSDN:
The process is assigned a 32-bit process identifier. The identifier is valid until the process terminates. It can be used to identify the process, or specified in the OpenProcess function to open a handle to the process. The initial thread in the process is also assigned a 32-bit thread identifier. The identifier is valid until the thread terminates and can be used to uniquely identify the thread within the system. These identifiers are returned in the PROCESS_INFORMATION structure.
Über diesen Identifier kannst du dann mit OpenProcess versuchen dieses Programm zu öffnen, falls es noch nicht terminiert wurde!
Auf gut C++:
_CreateProcess („c:\MainMailProg.exe“, …, …, lpProcessInformation, …);
MailProcessID = lpProcessInformation->dwProcessId;
if (OpenProcess(MailProcessID))
{
//Process läuft noch
}
else
{
//ProcessID existiert nicht --> Process schon terminiert.
}_
Ich hoffe wiedermal auf ein erfolgreiches 5te-Mal,
KoRn!