<?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[Restarter für zwei .exe]]></title><description><![CDATA[<p>Hi Ich möchte gerne einen Restarter für 2 EXE Dateien schreiben.<br />
Das heißt, ganz am Anfang sollen beide starten und wenn eine geschlossen wird soll sie wieder gestartet werden.</p>
<p>Ich hab c++ schon ne Weile in gebrauch, aber mit WinApi gehts gerade erst los...</p>
<p>Hier der Code:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;iostream&gt;
using namespace std;

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = &quot;CodeBlocksWindowsApp&quot;;

int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&amp;wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           &quot;Philles Restarter&quot;,       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           200,                 /* The programs width */
           200,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hButton, hButton2, hButton3;
    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
        {
            hButton = CreateWindow(  &quot;button&quot;,
                                  &quot;Beenden&quot;,
                                  WS_CHILD | WS_VISIBLE,
                                  0, 0, 0, 0,
                                  hwnd,
                                  NULL,
                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                  NULL);
            hButton2 = CreateWindow(  &quot;button&quot;,
                                  &quot;2.exe&quot;,
                                  WS_CHILD | WS_VISIBLE,
                                  0, 0, 0, 0,
                                  hwnd,
                                  NULL,
                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                  NULL);
            hButton3 = CreateWindow(  &quot;button&quot;,
                                  &quot;1.exe&quot;,
                                  WS_CHILD | WS_VISIBLE,
                                  0, 0, 0, 0,
                                  hwnd,
                                  NULL,
                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                  NULL);
            return 0;
        }
        case WM_SIZE:
        {
            MoveWindow(hButton, 15, 120, 160, 25, TRUE);
            MoveWindow(hButton2, 15, 30, 160, 25, TRUE);
            MoveWindow(hButton3, 15, 70, 160, 25, TRUE);
            return 0;
        }

        case WM_COMMAND:
        {
            if (lParam == (LPARAM)hButton)
            {
                if (HIWORD(wParam) == BN_CLICKED)
                cout &lt;&lt; &quot;Beenden&quot;;
                SendMessage(hwnd, WM_CLOSE, 0, 0);
            }

            if (lParam == (LPARAM)hButton2) {
                if (HIWORD(wParam) == BN_CLICKED)
                    cout &lt;&lt; &quot;reamld.exe&quot; &lt;&lt; endl;
                    system(&quot;start 1.exe&quot;); //Das hier muss irgendwie umgeändert werden
            }

            if (lParam == (LPARAM)hButton3) {
                if (HIWORD(wParam) == BN_CLICKED)
                    cout &lt;&lt; &quot;mangosd.exe&quot; &lt;&lt; endl;
                    system(&quot;start 2.exe&quot;); // Und das!
            }
            return 0;
        }
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>Ich hoffe jemand kann helfen</p>
<p>MfG Phille</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/212314/restarter-für-zwei-exe</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 06:11:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/212314.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 May 2008 16:58:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Restarter für zwei .exe on Sun, 04 May 2008 16:58:29 GMT]]></title><description><![CDATA[<p>Hi Ich möchte gerne einen Restarter für 2 EXE Dateien schreiben.<br />
Das heißt, ganz am Anfang sollen beide starten und wenn eine geschlossen wird soll sie wieder gestartet werden.</p>
<p>Ich hab c++ schon ne Weile in gebrauch, aber mit WinApi gehts gerade erst los...</p>
<p>Hier der Code:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;iostream&gt;
using namespace std;

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = &quot;CodeBlocksWindowsApp&quot;;

int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&amp;wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           &quot;Philles Restarter&quot;,       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           200,                 /* The programs width */
           200,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HWND hButton, hButton2, hButton3;
    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:
        {
            hButton = CreateWindow(  &quot;button&quot;,
                                  &quot;Beenden&quot;,
                                  WS_CHILD | WS_VISIBLE,
                                  0, 0, 0, 0,
                                  hwnd,
                                  NULL,
                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                  NULL);
            hButton2 = CreateWindow(  &quot;button&quot;,
                                  &quot;2.exe&quot;,
                                  WS_CHILD | WS_VISIBLE,
                                  0, 0, 0, 0,
                                  hwnd,
                                  NULL,
                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                  NULL);
            hButton3 = CreateWindow(  &quot;button&quot;,
                                  &quot;1.exe&quot;,
                                  WS_CHILD | WS_VISIBLE,
                                  0, 0, 0, 0,
                                  hwnd,
                                  NULL,
                                  ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                  NULL);
            return 0;
        }
        case WM_SIZE:
        {
            MoveWindow(hButton, 15, 120, 160, 25, TRUE);
            MoveWindow(hButton2, 15, 30, 160, 25, TRUE);
            MoveWindow(hButton3, 15, 70, 160, 25, TRUE);
            return 0;
        }

        case WM_COMMAND:
        {
            if (lParam == (LPARAM)hButton)
            {
                if (HIWORD(wParam) == BN_CLICKED)
                cout &lt;&lt; &quot;Beenden&quot;;
                SendMessage(hwnd, WM_CLOSE, 0, 0);
            }

            if (lParam == (LPARAM)hButton2) {
                if (HIWORD(wParam) == BN_CLICKED)
                    cout &lt;&lt; &quot;reamld.exe&quot; &lt;&lt; endl;
                    system(&quot;start 1.exe&quot;); //Das hier muss irgendwie umgeändert werden
            }

            if (lParam == (LPARAM)hButton3) {
                if (HIWORD(wParam) == BN_CLICKED)
                    cout &lt;&lt; &quot;mangosd.exe&quot; &lt;&lt; endl;
                    system(&quot;start 2.exe&quot;); // Und das!
            }
            return 0;
        }
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>Ich hoffe jemand kann helfen</p>
<p>MfG Phille</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503209</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503209</guid><dc:creator><![CDATA[Phille]]></dc:creator><pubDate>Sun, 04 May 2008 16:58:29 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Sun, 04 May 2008 20:51:10 GMT]]></title><description><![CDATA[<p>Virus?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503339</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503339</guid><dc:creator><![CDATA[Virus?]]></dc:creator><pubDate>Sun, 04 May 2008 20:51:10 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Mon, 05 May 2008 19:54:08 GMT]]></title><description><![CDATA[<p>Hallo Phille</p>
<p>Zu dem Problem mit dem system..</p>
<pre><code class="language-cpp">system(&quot;C:\\ordner\\nocheinordner\\blub\\deinedatei.exe&quot;);
</code></pre>
<p>und zu dem neustarten :</p>
<p>mach doch einfach eine endlosschleife (am besten mit sleep( &gt;= 5000))<br />
die mit findwindow oder ähnlichen funktionen abfragt ob dein prozess noch läuft.</p>
<pre><code class="language-cpp">if (!FindWindow(0, hierdernamedesfenstersdeinerexe))
</code></pre>
<p>und dann startest du die einfach neu (mit system oder CreateProcess)</p>
<p>Virus? schrieb:</p>
<blockquote>
<p>Virus?</p>
</blockquote>
<p>ich denke nicht dass das Neustarten eines Prozesses sehr nach einem Virus<br />
klingt. (Damit das Klappt müsste der virus ein fenster haben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /> )</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503870</guid><dc:creator><![CDATA[helferlein]]></dc:creator><pubDate>Mon, 05 May 2008 19:54:08 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Mon, 05 May 2008 20:14:40 GMT]]></title><description><![CDATA[<p>Phille könnte die beiden Exen auch einfach mit CreateProcess starten.</p>
<p>da hat er dann auch gleich die Prozess-Handles und kann mit WaitForMultipleObjects<br />
auf das Beenden einer der beiden reagieren.<br />
hat den Vorteil, dass man diese Technik auch bei Zielanwendungen ohne Fenster nutzen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1503884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1503884</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Mon, 05 May 2008 20:14:40 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Tue, 06 May 2008 19:29:49 GMT]]></title><description><![CDATA[<p>Vielen dank...<br />
Ne is nicht für Virus... Warum sollte ich das in ne Aplication machen?<br />
Das ist für einen Server.</p>
<p>Nochmal vielen dank</p>
<p>Phille</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1504477</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1504477</guid><dc:creator><![CDATA[Phille]]></dc:creator><pubDate>Tue, 06 May 2008 19:29:49 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Tue, 06 May 2008 20:01:01 GMT]]></title><description><![CDATA[<p>Ich habs ein bisschen ausprobiert.<br />
Aber ich kanns nicht so richtig realisieren.<br />
Wenn die Endlosschleife läuft soll man ja auch auf einen Button drücken können...<br />
Wie soll ich das machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1504496</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1504496</guid><dc:creator><![CDATA[Phille]]></dc:creator><pubDate>Tue, 06 May 2008 20:01:01 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Tue, 06 May 2008 20:33:06 GMT]]></title><description><![CDATA[<p>Threads!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1504523</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1504523</guid><dc:creator><![CDATA[dust]]></dc:creator><pubDate>Tue, 06 May 2008 20:33:06 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Wed, 07 May 2008 11:57:28 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/20597">@Phille</a>: pass auf, dass Blizzard sich nich bei dir meldet <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";-)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1504814</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1504814</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Wed, 07 May 2008 11:57:28 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Wed, 07 May 2008 15:04:24 GMT]]></title><description><![CDATA[<p>Ich hab den Thread mal bei Blizzard gemeldet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1504972</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1504972</guid><dc:creator><![CDATA[Threads!]]></dc:creator><pubDate>Wed, 07 May 2008 15:04:24 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Wed, 07 May 2008 15:26:43 GMT]]></title><description><![CDATA[<p>was soll das hier? ich weiss nicht was dümmer ist, der code mit dem system müll oder die ratschläge, die ihr hier erteilt. <strong>wie wärs mal mit CreateProcess und WaitForSingleObject</strong>. lol system, als nächstes kommt der eine hier wieder mit WinExec an oder wsa? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1504989</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1504989</guid><dc:creator><![CDATA[haterskater]]></dc:creator><pubDate>Wed, 07 May 2008 15:26:43 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Wed, 07 May 2008 15:28:45 GMT]]></title><description><![CDATA[<p>hallo rofler</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1504994</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1504994</guid><dc:creator><![CDATA[huhuh]]></dc:creator><pubDate>Wed, 07 May 2008 15:28:45 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Wed, 07 May 2008 17:40:31 GMT]]></title><description><![CDATA[<p>! hey, ich hab gesagt CreateProcess und außerdem solltest du beachten, dass es 2 Programe sind,<br />
also bitte: WaitForMultipleObjects !!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1505051</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1505051</guid><dc:creator><![CDATA[DrakoXP]]></dc:creator><pubDate>Wed, 07 May 2008 17:40:31 GMT</pubDate></item><item><title><![CDATA[Reply to Restarter für zwei .exe on Fri, 30 May 2008 13:34:59 GMT]]></title><description><![CDATA[<p>9KTH9r comment3,</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1519774</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1519774</guid><dc:creator><![CDATA[Gbgrobft]]></dc:creator><pubDate>Fri, 30 May 2008 13:34:59 GMT</pubDate></item></channel></rss>