<?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[Anwendung auf knopfdruck restarten]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>gibt es einen Befehl, mit dem ich auf Knopfdruck meine Anwendung beenden kann und diese dann anschliessend wieder automatisch startet ?</p>
<p>Gruss<br />
chloe</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/133506/anwendung-auf-knopfdruck-restarten</link><generator>RSS for Node</generator><lastBuildDate>Sat, 01 Aug 2026 13:51:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/133506.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Jan 2006 12:35:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anwendung auf knopfdruck restarten on Wed, 18 Jan 2006 12:35:51 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>gibt es einen Befehl, mit dem ich auf Knopfdruck meine Anwendung beenden kann und diese dann anschliessend wieder automatisch startet ?</p>
<p>Gruss<br />
chloe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969676</guid><dc:creator><![CDATA[chloe]]></dc:creator><pubDate>Wed, 18 Jan 2006 12:35:51 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung auf knopfdruck restarten on Wed, 18 Jan 2006 12:38:12 GMT]]></title><description><![CDATA[<p>Solange Du keinen Mutex o.ä. einsetzt, reicht es doch die Anwendung per ShellExecute neu zu starten und dann erst die laufende Instanz zu beenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969678</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969678</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 18 Jan 2006 12:38:12 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung auf knopfdruck restarten on Wed, 18 Jan 2006 12:39:47 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>sollte grundsätzlich mit einem</p>
<pre><code class="language-cpp">ShellExecute(&lt;Name des eigenes Programms&gt;) ;
Application-&gt;Terminate();
</code></pre>
<p>gehen</p>
<p>Allerdings dürfte eine saubere interne Reinitialisierung besser sein.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969681</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969681</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 18 Jan 2006 12:39:47 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung auf knopfdruck restarten on Wed, 18 Jan 2006 13:25:21 GMT]]></title><description><![CDATA[<p>Vielen Dank hat funktioniert!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969722</guid><dc:creator><![CDATA[chloe]]></dc:creator><pubDate>Wed, 18 Jan 2006 13:25:21 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung auf knopfdruck restarten on Wed, 18 Jan 2006 14:55:46 GMT]]></title><description><![CDATA[<p>hier mal ein kleines beispiel falls du nen mutex hast (konsolenexperte und konsolen-anwendung deaktivieren damit man die WinMain bekommt):</p>
<p><strong>Programmtitel</strong> ist der Name deines Programms. Das Programm wartet nun bis die Anwendung mit dem Titel <strong>Programmtitel</strong> nicht mehr gefunden wird und startet sie dann erneut.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

WINAPI WinMain(HINSTANCE handle, HINSTANCE, LPSTR CmdLine, int)
{
  // warten bis Anwendung nicht mehr gefunden wird
  while (FindWindow(NULL, &quot;Programmtitel&quot;)) Sleep(250);

  LPTSTR filepath = new TCHAR[MAX_PATH];

  // aktuelles verzeichnis holen
  if (GetModuleFileName(handle, filepath, MAX_PATH))
  {
    char drive[_MAX_DRIVE];
    char dir[_MAX_DIR];
    char file[_MAX_FNAME];
    char ext[_MAX_EXT];

    // pfad extrahieren
    _splitpath(filepath, drive, dir, file, ext);
    _makepath(filepath, drive, dir, &quot;&quot;, &quot;&quot;);

    if (((int) ShellExecute(NULL, &quot;open&quot;, strcat(filepath, CmdLine), NULL, NULL, SW_SHOWNORMAL)) &lt;= 32)
      MessageBox((HWND) handle, &quot;Fehler beim Neustarten der Anwendung...&quot;, &quot;Fehler&quot;, MB_OK);
  }

  delete [] filepath;

  return 0;
}
</code></pre>
<p>das kompilieren und die exe in das Verzeichnis deiner anwendung legen.<br />
in deinem eigentlichen Programm machst du dir ne kleine hilfs-funktion zum neustarten:</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
// Startet die Anwendung neu
//---------------------------------------------------------------------------
void AutoRestart()
{
  // Hilfsprogramm starten
  // -&gt; Pfad der Anwendung
  // -&gt; Name der Exe der Anwendung
  ShellExecute(0, &quot;open&quot;, (ExtractFilePath(Application-&gt;ExeName) + &quot;restart.exe&quot;).c_str(), 
               ExtractFileName(Application-&gt;ExeName).c_str(), 0, SW_SHOWNORMAL);

  // Anwendung abschießen              
  Application-&gt;ProcessMessages();
  Application-&gt;Terminate();
  Application-&gt;ProcessMessages();
}
</code></pre>
<p>ist schon ein paar jahre alt der code und schon lange nicht mehr gepflegt wurden, aber ich hoffe es funktioniert noch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/969803</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/969803</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Wed, 18 Jan 2006 14:55:46 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung auf knopfdruck restarten on Sat, 04 Feb 2006 13:45:37 GMT]]></title><description><![CDATA[<p>akari schrieb:</p>
<blockquote>
<p>Hallo</p>
<p>sollte grundsätzlich mit einem</p>
<pre><code class="language-cpp">ShellExecute(&lt;Name des eigenes Programms&gt;) ;
Application-&gt;Terminate();
</code></pre>
<p>gehen</p>
<p>Allerdings dürfte eine saubere interne Reinitialisierung besser sein.</p>
<p>bis bald<br />
akari</p>
</blockquote>
<p>laut kompiler sind das zu wenig parameter!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/985657</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/985657</guid><dc:creator><![CDATA[BigBanana]]></dc:creator><pubDate>Sat, 04 Feb 2006 13:45:37 GMT</pubDate></item><item><title><![CDATA[Reply to Anwendung auf knopfdruck restarten on Sat, 04 Feb 2006 13:52:38 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>ich habe extra <em>grundsätzlich</em> dazu geschrieben.<br />
Wenn du die Forumssucher benutzt hättest, hättest du zum Beispiel <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-119418-and-highlight-is-%2Ashellexecute%2A.html" rel="nofollow">diesen Thread</a> gefunden, der dich über die vollständige Syntax der Funktion<br />
aufklärt.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/985660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/985660</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sat, 04 Feb 2006 13:52:38 GMT</pubDate></item></channel></rss>