C
Hallo,
also ich möchte gerne ein Programm in bestimmten Zeitabständen starten. Dazu verwende ich die Funktion CreateProcess(). Wenn ich meinen Dienst debugge dann funktioniert das alles auch wunderbar, aber halt immer nur im Debugmodus.
Ich poste mal meinen Code...vielleicht kann mir ja einer auf die Sprünge helfen.
void __fastcall TMtws32Service::UeberwachungTimerTimer(TObject *Sender)
{
HWND nErr = NULL;
STARTUPINFO si;
PROCESS_INFORMATION pi;
char szInstallDir[100];
AnsiString dbpathname;
memset(&si, 0, sizeof(si));
ZeroMemory( &si, sizeof(STARTUPINFO) );
ZeroMemory( &pi, sizeof(PROCESS_INFORMATION) );
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
try
{
nErr = FindWindow( NULL , "MTWS32 Version 3.4" );
if( nErr != NULL )
{
LogError("MTWS32 ist noch am Leben");
}
else
{
if ( !ReadMTWS32RegStr( "", szRegInstallDir, szInstallDir, sizeof(szInstallDir) ) )
{
LogError ("Finde den Pfad nicht");
}
else
{
dbpathname = AnsiString(szInstallDir) + "\\mtws32.exe" ;
}
// Start the child process.
if (CreateProcess(NULL,
dbpathname.c_str(), // path of installed mtws
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
NORMAL_PRIORITY_CLASS , //creation flags.
NULL, // Use parent's environment block.
szInstallDir, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi )) // Pointer to PROCESS_INFORMATION
{
LogError("create process hat funktioniert");
}
else
{
LogError(AnsiString(GetLastError()).c_str());
}
}
}
catch (Exception &exception)
{
Sysutils::ShowException(&exception, Sysutils::ExceptAddr());
}
}
Übrigens die Eigenschaft Interactive hab ich auf true gesetzt. In meiner *.log datei steht komischerweise auch immer "createprocess hat funktioniert", nur eben ist die exe datei im taskmanager nirgends zu finden.
hoffe mir kann jemand helfen!
und danke schon mal im voraus