<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Warten bis Process zuende]]></title><description><![CDATA[<p>Hallo Forum,</p>
<p>ich möchte dem User eine Anwendung zeigen und mit meinem Programm erst fortfahren bis diese beendet wurde. Im Web habe ich schon einiges gefunden, darunter auch aus diesem Forum (<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-236041.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-236041.html</a>), ich komme jedoch nicht weiter:</p>
<pre><code class="language-cpp">// Startet einen Task.
// Path: Pfad zur Anwendung
// WithTermination: Beendet ggf die gestartete Anwendung wenn MaxZeit überschritten.
// WaitForTermination: Warten bis Programm beendet oder MaxZeit erreicht.
void StartTask(char *Path, int WithTermination, int WaitForTermination) {

	STARTUPINFO si;
	PROCESS_INFORMATION pi;

	memset(&amp;si, 0 ,sizeof(si));
    si.cb= sizeof(si);
    si.wShowWindow = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_SHOWDEFAULT;
	memset(&amp;pi, 0 ,sizeof(pi));

	CreateProcess(
		NULL,
		Path,
		NULL,
		NULL,
		FALSE,
		CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS,
		NULL,
		NULL,
		&amp;si,
		&amp;pi);

    int retval=0;
    if (WaitForTermination==TRUE) {
        retval = WaitForSingleObject(pi.hProcess, 10000);
    }

    // Beendet ggf den gestarteten Task:
    if (WithTermination) {
        CloseHandle(pi.hProcess);
        CloseHandle(pi.hThread);
    }
}
</code></pre>
<p>Meine Problem ist das WaitForSingleObject() immer 0 zurückgibt.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/241582/warten-bis-process-zuende</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Apr 2026 00:01:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/241582.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 22 May 2009 18:35:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Warten bis Process zuende on Fri, 22 May 2009 18:35:34 GMT]]></title><description><![CDATA[<p>Hallo Forum,</p>
<p>ich möchte dem User eine Anwendung zeigen und mit meinem Programm erst fortfahren bis diese beendet wurde. Im Web habe ich schon einiges gefunden, darunter auch aus diesem Forum (<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-236041.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-236041.html</a>), ich komme jedoch nicht weiter:</p>
<pre><code class="language-cpp">// Startet einen Task.
// Path: Pfad zur Anwendung
// WithTermination: Beendet ggf die gestartete Anwendung wenn MaxZeit überschritten.
// WaitForTermination: Warten bis Programm beendet oder MaxZeit erreicht.
void StartTask(char *Path, int WithTermination, int WaitForTermination) {

	STARTUPINFO si;
	PROCESS_INFORMATION pi;

	memset(&amp;si, 0 ,sizeof(si));
    si.cb= sizeof(si);
    si.wShowWindow = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_SHOWDEFAULT;
	memset(&amp;pi, 0 ,sizeof(pi));

	CreateProcess(
		NULL,
		Path,
		NULL,
		NULL,
		FALSE,
		CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS,
		NULL,
		NULL,
		&amp;si,
		&amp;pi);

    int retval=0;
    if (WaitForTermination==TRUE) {
        retval = WaitForSingleObject(pi.hProcess, 10000);
    }

    // Beendet ggf den gestarteten Task:
    if (WithTermination) {
        CloseHandle(pi.hProcess);
        CloseHandle(pi.hThread);
    }
}
</code></pre>
<p>Meine Problem ist das WaitForSingleObject() immer 0 zurückgibt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1714371</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1714371</guid><dc:creator><![CDATA[abcd]]></dc:creator><pubDate>Fri, 22 May 2009 18:35:34 GMT</pubDate></item><item><title><![CDATA[Reply to Warten bis Process zuende on Fri, 22 May 2009 18:51:17 GMT]]></title><description><![CDATA[<p>GetLastError() &amp; FormatMessage() = ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1714376</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1714376</guid><dc:creator><![CDATA[Input]]></dc:creator><pubDate>Fri, 22 May 2009 18:51:17 GMT</pubDate></item><item><title><![CDATA[Reply to Warten bis Process zuende on Fri, 22 May 2009 19:00:42 GMT]]></title><description><![CDATA[<p>Ich habe jetzt diese Zeilen eingefügt:</p>
<pre><code class="language-cpp">char errBuf[1000];
memset(&amp;errBuf, 0 ,sizeof(char)*1000);
int dwError = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)errBuf,0,NULL);
MessageBox(NULL, (LPCTSTR)errBuf, NULL, MB_OK);
</code></pre>
<p>Die zu startende Anwendung startet normal, dwError==0 und in der Messagebox steht gar nichts.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1714380</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1714380</guid><dc:creator><![CDATA[abcd]]></dc:creator><pubDate>Fri, 22 May 2009 19:00:42 GMT</pubDate></item><item><title><![CDATA[Reply to Warten bis Process zuende on Fri, 22 May 2009 19:29:35 GMT]]></title><description><![CDATA[<p>msdn:</p>
<blockquote>
<p>WAIT_OBJECT_0 0x00000000L The state of the specified object is signaled</p>
</blockquote>
<p>wo ist also dein problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1714386</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1714386</guid><dc:creator><![CDATA[sothis_]]></dc:creator><pubDate>Fri, 22 May 2009 19:29:35 GMT</pubDate></item><item><title><![CDATA[Reply to Warten bis Process zuende on Fri, 22 May 2009 19:51:22 GMT]]></title><description><![CDATA[<p>Der Wartezeitraum in WaitForSingleObject() ist 10 Sekunden. Aber egal ob ich das gestartete Programm in der Zeit offen lasse oder schließe retval ist immer 0 und bei WaitForSingleObject() wird auch nicht 10 Sekunden gewarte. (So habe ich jedenfalls WaitForSingleObject verstanden.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1714399</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1714399</guid><dc:creator><![CDATA[abcd]]></dc:creator><pubDate>Fri, 22 May 2009 19:51:22 GMT</pubDate></item></channel></rss>