<?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[Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?!]]></title><description><![CDATA[<p>Hallo Community <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Ich habe seid ein paar Tagen mit C++ angefangen und ich muss sagen es gefällt mir <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Frage1:<br />
Ich wollte ein Programm schreiben was in der Console ein Programm starten kann, dies in einer Do-Schleife.<br />
Ich weiß jetzt aber nicht, wie ich es machen kann das wenn man case2 ausgewählt hat , entweder wieder von neu anfängt oder eine neue Abfrage.</p>
<p>Frage2:<br />
Bei Case1: soll das Programm gestartet werden ,was im gleichen Ordner ist.<br />
Den Befehl für den Ordner wo die C++ anwendung drin ist habe ich schon, aber ich wüsste nicht wie ich es mit ShellExecute machen könnte.<br />
Das Programm was ich noch starten will sollte mit den Parametern &quot;22 22&quot; gestartet werden (:</p>
<p>Mit freundlichen Grüßen</p>
<p>Ich wäre sehr glücklich wenn mir jemand helfen könnte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<pre><code class="language-cli">// main.cpp : Defines the entry point for the console application.
//
#include &quot;stdafx.h&quot;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;windows.h&gt;
# include&lt;shellapi.h&gt; 
#include &lt;direct.h&gt; // for getcwd
#include &lt;conio.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

// function to return the current working directory
// this is generally the application path
void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}

int _tmain(int argc, _TCHAR* argv[])
{	
	/*Variablen &amp; String's !
	int Zahl = 300 ; 
	cout &lt;&lt; Zahl ;
	//*************************
	string Vorname;
	cout &lt;&lt; &quot;Vornamen eingeben: &quot; ;
    cin  &gt;&gt; Vorname;
	cout &lt;&lt; &quot;\n\n\n&quot; &lt;&lt; &quot;Hallo &quot; &lt;&lt; Vorname &lt;&lt; &quot;!&quot; ;*/

	// Allgemein
	int x;
	SetConsoleTitleA(&quot;Console by Alexander&quot;);
	cout &lt;&lt; &quot;Programm Name\n&quot; ;
	cout &lt;&lt; &quot;******************************************************************\n\n&quot; ;
	cout &lt;&lt; &quot;Welcome, don't forget to make a donation if you like this tool.\n&quot; ;
	cout &lt;&lt; &quot;This tool is free DO NOT SELL IT ON EBAY!!\n&quot; ;
	cout &lt;&lt; &quot;Write me an E-mail at  info[at]the-franky.de\n\n&quot; ;
	cout &lt;&lt; &quot;******************************************************************\n&quot; ;
	cout &lt;&lt; &quot;Do you want so start it ?\n\n&quot;;
	cout &lt;&lt; &quot;1: Starting the Programm !\n&quot;;
	cout &lt;&lt; &quot;2: Your Help !\n&quot;;
	cout &lt;&lt; &quot;0: Exit.\n\n&quot;;

	do
		{
		cout &lt;&lt; &quot;Please Select: &quot;;
		cin &gt;&gt; x;
		}while((x&lt;0)||(x&gt;2)); // x != 3

	switch(x)
		{
			case 1: system(&quot;cls&quot;);	
				// _MAX_PATH is the maximum length allowed for a path
				char CurrentPath[_MAX_PATH];
				// use the function to get the path
				GetCurrentPath(CurrentPath);
				// display the path for demo purposes only
				char temp[_MAX_PATH];
				cout &lt;&lt; CurrentPath &lt;&lt; endl;
				cin.getline(temp,_MAX_PATH);
				cout &lt;&lt; &quot;\n******************************************************************\n&quot; ;
				cout &lt;&lt; &quot;              Warning the programm is now running !&quot; ;
				cout &lt;&lt; &quot;\n******************************************************************\n&quot; ;
				cout &lt;&lt; &quot;\nSuccessfully.\n&quot; ;
				cout &lt;&lt; &quot;\nPush any Key to EXIT the Programm, be carefull.&quot;;
				// 
				ShellExecute(
				NULL,
				_T(&quot;open&quot;),                     
				_T(&quot;Programm.exe&quot;), // Ist im gleichen Ordner
				_T(&quot;22 22&quot;), // Programm mit 22 22 ausführen                          
				_T(&quot; C:\ &quot;), 
				SW_SHOW);
				break ;
			case 2: system(&quot;cls&quot;);
					cout &lt;&lt; &quot;******************************************************************&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;                            Your Help !&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;******************************************************************&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;Write an E-mail with 'Help Me' at  info[at]the-franky.de&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;Thank you for your understanding\n&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;******************************************************************\n\n&quot; ;
					cout &lt;&lt; &quot;Do you want so start it now?\n\n&quot;;
					cout &lt;&lt; &quot;1: Starting the Programm !\n&quot;;
					cout &lt;&lt; &quot;0: Exit.\n\n&quot;;
					int y;
						do
						{
							cout &lt;&lt; &quot;Please Select: &quot;;
							cin &gt;&gt; y;
						}while((x&lt;0)||(x&gt;1));
							switch(y)
						{
							case 0:
								cout &lt;&lt; &quot;DIE NULL&quot;;
							case 1:
								cout &lt;&lt; &quot;DIE EINS&quot;;
						}
			case 0: exit (1);		
		}	
	//system(&quot;pause&quot;);
	_getch();
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/279421/console-do-in-do-schleife-amp-programm-ausführen-mit-parameter</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 14:22:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/279421.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 26 Dec 2010 16:43:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?! on Sun, 26 Dec 2010 16:43:07 GMT]]></title><description><![CDATA[<p>Hallo Community <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Ich habe seid ein paar Tagen mit C++ angefangen und ich muss sagen es gefällt mir <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Frage1:<br />
Ich wollte ein Programm schreiben was in der Console ein Programm starten kann, dies in einer Do-Schleife.<br />
Ich weiß jetzt aber nicht, wie ich es machen kann das wenn man case2 ausgewählt hat , entweder wieder von neu anfängt oder eine neue Abfrage.</p>
<p>Frage2:<br />
Bei Case1: soll das Programm gestartet werden ,was im gleichen Ordner ist.<br />
Den Befehl für den Ordner wo die C++ anwendung drin ist habe ich schon, aber ich wüsste nicht wie ich es mit ShellExecute machen könnte.<br />
Das Programm was ich noch starten will sollte mit den Parametern &quot;22 22&quot; gestartet werden (:</p>
<p>Mit freundlichen Grüßen</p>
<p>Ich wäre sehr glücklich wenn mir jemand helfen könnte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<pre><code class="language-cli">// main.cpp : Defines the entry point for the console application.
//
#include &quot;stdafx.h&quot;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;windows.h&gt;
# include&lt;shellapi.h&gt; 
#include &lt;direct.h&gt; // for getcwd
#include &lt;conio.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

// function to return the current working directory
// this is generally the application path
void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}

int _tmain(int argc, _TCHAR* argv[])
{	
	/*Variablen &amp; String's !
	int Zahl = 300 ; 
	cout &lt;&lt; Zahl ;
	//*************************
	string Vorname;
	cout &lt;&lt; &quot;Vornamen eingeben: &quot; ;
    cin  &gt;&gt; Vorname;
	cout &lt;&lt; &quot;\n\n\n&quot; &lt;&lt; &quot;Hallo &quot; &lt;&lt; Vorname &lt;&lt; &quot;!&quot; ;*/

	// Allgemein
	int x;
	SetConsoleTitleA(&quot;Console by Alexander&quot;);
	cout &lt;&lt; &quot;Programm Name\n&quot; ;
	cout &lt;&lt; &quot;******************************************************************\n\n&quot; ;
	cout &lt;&lt; &quot;Welcome, don't forget to make a donation if you like this tool.\n&quot; ;
	cout &lt;&lt; &quot;This tool is free DO NOT SELL IT ON EBAY!!\n&quot; ;
	cout &lt;&lt; &quot;Write me an E-mail at  info[at]the-franky.de\n\n&quot; ;
	cout &lt;&lt; &quot;******************************************************************\n&quot; ;
	cout &lt;&lt; &quot;Do you want so start it ?\n\n&quot;;
	cout &lt;&lt; &quot;1: Starting the Programm !\n&quot;;
	cout &lt;&lt; &quot;2: Your Help !\n&quot;;
	cout &lt;&lt; &quot;0: Exit.\n\n&quot;;

	do
		{
		cout &lt;&lt; &quot;Please Select: &quot;;
		cin &gt;&gt; x;
		}while((x&lt;0)||(x&gt;2)); // x != 3

	switch(x)
		{
			case 1: system(&quot;cls&quot;);	
				// _MAX_PATH is the maximum length allowed for a path
				char CurrentPath[_MAX_PATH];
				// use the function to get the path
				GetCurrentPath(CurrentPath);
				// display the path for demo purposes only
				char temp[_MAX_PATH];
				cout &lt;&lt; CurrentPath &lt;&lt; endl;
				cin.getline(temp,_MAX_PATH);
				cout &lt;&lt; &quot;\n******************************************************************\n&quot; ;
				cout &lt;&lt; &quot;              Warning the programm is now running !&quot; ;
				cout &lt;&lt; &quot;\n******************************************************************\n&quot; ;
				cout &lt;&lt; &quot;\nSuccessfully.\n&quot; ;
				cout &lt;&lt; &quot;\nPush any Key to EXIT the Programm, be carefull.&quot;;
				// 
				ShellExecute(
				NULL,
				_T(&quot;open&quot;),                     
				_T(&quot;Programm.exe&quot;), // Ist im gleichen Ordner
				_T(&quot;22 22&quot;), // Programm mit 22 22 ausführen                          
				_T(&quot; C:\ &quot;), 
				SW_SHOW);
				break ;
			case 2: system(&quot;cls&quot;);
					cout &lt;&lt; &quot;******************************************************************&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;                            Your Help !&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;******************************************************************&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;Write an E-mail with 'Help Me' at  info[at]the-franky.de&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;Thank you for your understanding\n&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;******************************************************************\n\n&quot; ;
					cout &lt;&lt; &quot;Do you want so start it now?\n\n&quot;;
					cout &lt;&lt; &quot;1: Starting the Programm !\n&quot;;
					cout &lt;&lt; &quot;0: Exit.\n\n&quot;;
					int y;
						do
						{
							cout &lt;&lt; &quot;Please Select: &quot;;
							cin &gt;&gt; y;
						}while((x&lt;0)||(x&gt;1));
							switch(y)
						{
							case 0:
								cout &lt;&lt; &quot;DIE NULL&quot;;
							case 1:
								cout &lt;&lt; &quot;DIE EINS&quot;;
						}
			case 0: exit (1);		
		}	
	//system(&quot;pause&quot;);
	_getch();
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1999029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1999029</guid><dc:creator><![CDATA[0x33]]></dc:creator><pubDate>Sun, 26 Dec 2010 16:43:07 GMT</pubDate></item><item><title><![CDATA[Reply to Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?! on Sun, 26 Dec 2010 17:33:56 GMT]]></title><description><![CDATA[<p>0x33 schrieb:</p>
<blockquote>
<p>Hallo Community <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Ich habe seid ein paar Tagen mit C++ angefangen und ich muss sagen es gefällt mir <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Frage1:<br />
Ich wollte ein Programm schreiben was in der Console ein Programm starten kann, dies in einer Do-Schleife.<br />
Ich weiß jetzt aber nicht, wie ich es machen kann das wenn man case2 ausgewählt hat , entweder wieder von neu anfängt oder eine neue Abfrage.</p>
</blockquote>
<pre><code class="language-cpp">do {
...
} while (x);
</code></pre>
<p>0x33 schrieb:</p>
<blockquote>
<p>Frage2:<br />
Bei Case1: soll das Programm gestartet werden ,was im gleichen Ordner ist.<br />
Den Befehl für den Ordner wo die C++ anwendung drin ist habe ich schon, aber ich wüsste nicht wie ich es mit ShellExecute machen könnte.<br />
Das Programm was ich noch starten will sollte mit den Parametern &quot;22 22&quot; gestartet werden (:</p>
<p>Mit freundlichen Grüßen</p>
<p>Ich wäre sehr glücklich wenn mir jemand helfen könnte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
</blockquote>
<p>Warum übergibst du dann für lpDirectory &quot;C:\&quot;?<br />
Das mal durchlesen: <a href="http://msdn.microsoft.com/en-us/library/bb762153%28v=vs.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/bb762153%28v=vs.85%29.aspx</a></p>
<p>Eigenartig, dass du dich gleich auf die WinAPI stürzt anstatt erstmal die Grundlagen von C++ zu lernen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1999043</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1999043</guid><dc:creator><![CDATA[inter2k3]]></dc:creator><pubDate>Sun, 26 Dec 2010 17:33:56 GMT</pubDate></item><item><title><![CDATA[Reply to Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?! on Sun, 26 Dec 2010 17:37:29 GMT]]></title><description><![CDATA[<p>Hey erstmal danke für die antwort <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Naja Zu Frage1 , ich habe ja</p>
<pre><code class="language-cpp">Do {
...
} while (x);
</code></pre>
<p>Nur Bei Case2: Habe ich dort nochmal eine Do-Schleife die nicht funktioniert.<br />
Warum ?</p>
<p>Regards</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1999045</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1999045</guid><dc:creator><![CDATA[0x33]]></dc:creator><pubDate>Sun, 26 Dec 2010 17:37:29 GMT</pubDate></item><item><title><![CDATA[Reply to Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?! on Sun, 26 Dec 2010 17:43:57 GMT]]></title><description><![CDATA[<p>0x33 schrieb:</p>
<blockquote>
<pre><code class="language-cpp">int y;
do
{
    cout &lt;&lt; &quot;Please Select: &quot;;
    cin &gt;&gt; y;
}while((x&lt;0)||(x&gt;1));
</code></pre>
</blockquote>
<p>Es sollte wahrscheinlich while ((y&lt;0) || (y&gt;1)) heissen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1999048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1999048</guid><dc:creator><![CDATA[inter2k3]]></dc:creator><pubDate>Sun, 26 Dec 2010 17:43:57 GMT</pubDate></item><item><title><![CDATA[Reply to Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?! on Sun, 26 Dec 2010 17:49:12 GMT]]></title><description><![CDATA[<p>Ich habs geändert zu 'while ((y&lt;0) || (y&gt;1)' , dass programm schmiert trozdem ab.<br />
Hier mal der jetzige Code.</p>
<p>Mit freundlichen Grüßen</p>
<pre><code class="language-cpp">// ipod.cpp : Defines the entry point for the console application.
//
#include &quot;stdafx.h&quot;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;windows.h&gt;
# include&lt;shellapi.h&gt; 
#include &lt;direct.h&gt; // for getcwd
#include &lt;conio.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

// function to return the current working directory
// this is generally the application path
void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}

int _tmain(int argc, _TCHAR* argv[])
{	
	/*Variablen &amp; String's !
	int Zahl = 300 ; 
	cout &lt;&lt; Zahl ;
	//*************************
	string Vorname;
	cout &lt;&lt; &quot;Vornamen eingeben: &quot; ;
    cin  &gt;&gt; Vorname;
	cout &lt;&lt; &quot;\n\n\n&quot; &lt;&lt; &quot;Hallo &quot; &lt;&lt; Vorname &lt;&lt; &quot;!&quot; ;*/

	// Allgemein
	int x;
	SetConsoleTitleA(&quot;Console by Alexander&quot;);
	cout &lt;&lt; &quot;Programm Name\n&quot; ;
	cout &lt;&lt; &quot;******************************************************************\n\n&quot; ;
	cout &lt;&lt; &quot;Welcome, don't forget to make a donation if you like this tool.\n&quot; ;
	cout &lt;&lt; &quot;This tool is free DO NOT SELL IT ON EBAY!!\n&quot; ;
	cout &lt;&lt; &quot;Write me an E-mail at  info[at]the-franky.de\n\n&quot; ;
	cout &lt;&lt; &quot;******************************************************************\n&quot; ;
	cout &lt;&lt; &quot;Do you want so start it ?\n\n&quot;;
	cout &lt;&lt; &quot;1: Starting the Programm !\n&quot;;
	cout &lt;&lt; &quot;2: Your Help !\n&quot;;
	cout &lt;&lt; &quot;0: Exit.\n\n&quot;;

	do
		{
		cout &lt;&lt; &quot;Please Select: &quot;;
		cin &gt;&gt; x;
		}while((x&lt;0)||(x&gt;2)); // x != 3

	switch(x)
		{
			case 1: system(&quot;cls&quot;);	
				// _MAX_PATH is the maximum length allowed for a path
				char CurrentPath[_MAX_PATH];
				// use the function to get the path
				GetCurrentPath(CurrentPath);
				// display the path for demo purposes only
				char temp[_MAX_PATH];
				cout &lt;&lt; CurrentPath &lt;&lt; endl;
				cin.getline(temp,_MAX_PATH);
				cout &lt;&lt; &quot;\n******************************************************************\n&quot; ;
				cout &lt;&lt; &quot;              Warning the programm is now running !&quot; ;
				cout &lt;&lt; &quot;\n******************************************************************\n&quot; ;
				cout &lt;&lt; &quot;\nSuccessfully.\n&quot; ;
				cout &lt;&lt; &quot;\nPush any Key to EXIT the Programm, be carefull.&quot;;
				// 
				ShellExecute(
				NULL,
				_T(&quot;open&quot;),                     
				_T(&quot;Programm.exe&quot;), // Ist im gleichen Ordner
				_T(&quot;22 22&quot;), // Programm mit 22 22 ausführen                          
				_T(&quot; C:\ &quot;), 
				SW_SHOW);
				break ;
			case 2: system(&quot;cls&quot;);
					cout &lt;&lt; &quot;******************************************************************&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;                            Your Help !&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;******************************************************************&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;Write an E-mail with 'Help Me' at  info[at]the-franky.de&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;Thank you for your understanding\n&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;******************************************************************\n\n&quot; ;
					cout &lt;&lt; &quot;Do you want so start it now?\n\n&quot;;
					cout &lt;&lt; &quot;1: Starting the Programm !\n&quot;;
					cout &lt;&lt; &quot;0: Exit.\n\n&quot;;
					int y;
						do
						{
							cout &lt;&lt; &quot;Please Select: &quot;;
							cin &gt;&gt; y;
						}while((y&lt;0)||(y&gt;1));
							switch(y)
						{
							case 0:
								cout &lt;&lt; &quot;DIE NULL&quot;;; break;
							case 1:
								cout &lt;&lt; &quot;DIE EINS&quot;;; break;
						}
			case 0: exit (1);		
		}	
	//system(&quot;pause&quot;);
	_getch();
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1999051</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1999051</guid><dc:creator><![CDATA[0x33]]></dc:creator><pubDate>Sun, 26 Dec 2010 17:49:12 GMT</pubDate></item><item><title><![CDATA[Reply to Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?! on Sun, 26 Dec 2010 18:42:36 GMT]]></title><description><![CDATA[<p>die schleife funktioniert, aber für die case anweisung fehlt noch ein break, denn ohne das break wird sofort zum nächsten case gesprungen und da dieser exit ist &quot;schmiert&quot; das programm ab</p>
<pre><code class="language-cpp">do
                        {
                            cout &lt;&lt; &quot;Please Select: &quot;;
                            cin &gt;&gt; y;
                        }while((y&lt;0)||(y&gt;1));
                            switch(y)
                        {
                            case 0:
                                cout &lt;&lt; &quot;DIE NULL&quot;;; break;
                            case 1:
                                cout &lt;&lt; &quot;DIE EINS&quot;;; break;
                        }
                        break; // hier fehlts
            case 0: exit (1);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1999074</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1999074</guid><dc:creator><![CDATA[Gucky]]></dc:creator><pubDate>Sun, 26 Dec 2010 18:42:36 GMT</pubDate></item><item><title><![CDATA[Reply to Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?! on Sun, 26 Dec 2010 20:32:47 GMT]]></title><description><![CDATA[<p>Hallo<br />
Ein riesen Dankeschön , es klappt wunderbar <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
Das mit Shellexecute habe ich nun auch geschafft (=</p>
<p>Nur wenn sich mein Programm beenden , beendet sich &quot;Das andere Programm&quot; nicht.<br />
Wie könnte ich machen , dass es sich beendet?</p>
<p>Ich habe es schon mit ...</p>
<pre><code class="language-cpp">HWND spiel=FindWindow(0, TEXT(&quot;Window Title&quot;));
SendMessage(spiel, WM_CLOSE, 0, 0);
</code></pre>
<p>probiert, da es aber eine CMD anwendung ist, ist der Title = Der Pfad, klappte nicht !</p>
<p>So habe ich es auch probiert...</p>
<pre><code class="language-cpp">void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}
// _MAX_PATH is the maximum length allowed for a path
char CurrentPath[_MAX_PATH];
// use the function to get the path
GetCurrentPath(CurrentPath);
// display the path for demo purposes only
char temp[_MAX_PATH];
cout &lt;&lt; CurrentPath &lt;&lt; endl;
cin.getline(temp,_MAX_PATH);

HWND spiel=FindWindow(0, TEXT(CurrentPath));
SendMessage(spiel, WM_CLOSE, 0, 0);
</code></pre>
<p>klappt aber auch nicht.</p>
<p>Frage: Wie könnte ich es machen , dass sich das externe CMD Programm sich sofort beendet , wenn sich mein programm beendet ?</p>
<p>Regards</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1999121</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1999121</guid><dc:creator><![CDATA[0x33]]></dc:creator><pubDate>Sun, 26 Dec 2010 20:32:47 GMT</pubDate></item><item><title><![CDATA[Reply to Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?! on Sun, 26 Dec 2010 20:45:17 GMT]]></title><description><![CDATA[<p>du öffnest mit deinem programm nur ein anderes und es besteht keine abhängigkeit.</p>
<p>hier ein beispiel wie man es mit der WinAPI machen kann:<br />
<a href="http://www.tutorials.de/c-c/181021-windows-prozess-killen-mit-c.html" rel="nofollow">http://www.tutorials.de/c-c/181021-windows-prozess-killen-mit-c.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1999128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1999128</guid><dc:creator><![CDATA[Gucky]]></dc:creator><pubDate>Sun, 26 Dec 2010 20:45:17 GMT</pubDate></item><item><title><![CDATA[Reply to Console Do in Do - schleife &amp;amp; Programm ausführen mit Parameter?! on Sun, 26 Dec 2010 21:32:03 GMT]]></title><description><![CDATA[<p>Danke für den Link, es klappt aber nicht.<br />
Hier mal der Code <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<pre><code class="language-cpp">// ipod.cpp : Defines the entry point for the console application.
//
#include &quot;stdafx.h&quot;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;tlhelp32.h&gt;
#include &lt;windows.h&gt;
# include&lt;shellapi.h&gt; 
#include &lt;direct.h&gt; // for getcwd
#include &lt;conio.h&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

// function to return the current working directory
// this is generally the application path
void GetCurrentPath(char* buffer)
{
getcwd(buffer, _MAX_PATH);
}
void printError( TCHAR* msg );
BOOL KillProcessByName(char *szProcessToKill);

int _tmain(int argc, _TCHAR* argv[])
{	
	/*Variablen &amp; String's !
	int Zahl = 300 ; 
	cout &lt;&lt; Zahl ;
	//*************************
	string Vorname;
	cout &lt;&lt; &quot;Vornamen eingeben: &quot; ;
    cin  &gt;&gt; Vorname;
	cout &lt;&lt; &quot;\n\n\n&quot; &lt;&lt; &quot;Hallo &quot; &lt;&lt; Vorname &lt;&lt; &quot;!&quot; ;*/

	// Allgemein
	int x;
	SetConsoleTitleA(&quot;Console by Alexander&quot;);
	cout &lt;&lt; &quot;Programm Name\n&quot; ;
	cout &lt;&lt; &quot;******************************************************************\n\n&quot; ;
	cout &lt;&lt; &quot;Welcome, don't forget to make a donation if you like this tool.\n&quot; ;
	cout &lt;&lt; &quot;This tool is free DO NOT SELL IT ON EBAY!!\n&quot; ;
	cout &lt;&lt; &quot;Write me an E-mail at  info[at]the-franky.de\n\n&quot; ;
	cout &lt;&lt; &quot;******************************************************************\n&quot; ;
	cout &lt;&lt; &quot;Do you want so start it ?\n\n&quot;;
	cout &lt;&lt; &quot;1: Starting the Programm !\n&quot;;
	cout &lt;&lt; &quot;2: Your Help !\n&quot;;
	cout &lt;&lt; &quot;0: Exit.\n\n&quot;;

	do
		{
		cout &lt;&lt; &quot;Please Select: &quot;;
		cin &gt;&gt; x;
		}while((x&lt;0)||(x&gt;2)); // x != 3

	switch(x)
		{
			case 1: system(&quot;cls&quot;);	
				// _MAX_PATH is the maximum length allowed for a path
				char CurrentPath[_MAX_PATH];
				// use the function to get the path
				GetCurrentPath(CurrentPath);
				// display the path for demo purposes only
				char temp[_MAX_PATH];
				cout &lt;&lt; CurrentPath &lt;&lt; endl;
				cin.getline(temp,_MAX_PATH);
				cout &lt;&lt; &quot;\n******************************************************************\n&quot; ;
				cout &lt;&lt; &quot;              Warning the programm is now running !&quot; ;
				cout &lt;&lt; &quot;\n******************************************************************\n&quot; ;
				cout &lt;&lt; &quot;\nSuccessfully.\n&quot; ;
				cout &lt;&lt; &quot;\nPush any Key to EXIT the Programm, be carefull.&quot;;
				// 
				ShellExecute(
				NULL,
				_T(&quot;open&quot;),                     
				_T(&quot;Externes Programm.exe&quot;), // Ist im gleichen Ordner
				_T(&quot;22 22&quot;), // Programm mit 22 22 ausführen                          
				NULL, 
				SW_MINIMIZE);
				break ;
			case 2: system(&quot;cls&quot;);
					cout &lt;&lt; &quot;******************************************************************&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;                            Your Help !&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;******************************************************************&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;Write an E-mail with 'Help Me' at  info[at]the-franky.de&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;Thank you for your understanding\n&quot; &lt;&lt; endl;
					cout &lt;&lt; &quot;******************************************************************\n\n&quot; ;
					cout &lt;&lt; &quot;Do you want so start it now?\n\n&quot;;
					cout &lt;&lt; &quot;1: Starting the Programm !\n&quot;;
					cout &lt;&lt; &quot;0: Exit.\n\n&quot;;
					int y;
						do
						{
							cout &lt;&lt; &quot;Please Select: &quot;;
							cin &gt;&gt; y;
						}while((y&lt;0)||(y&gt;1));
							switch(y)
						{
							case 0:
								cout &lt;&lt; &quot;DIE NULL&quot;;; break;
							case 1:
								cout &lt;&lt; &quot;DIE EINS&quot;;; break;
						}
							break ; // Für die andere Schleife
			case 0: exit (1);		
		}	
	//system(&quot;pause&quot;);
	KillProcessByName(&quot;Externes Programm.exe&quot;);      // Anstatt Icq.exe halt &quot;Test.exe&quot; eingeben!
	_getch();
	return 0;
}

BOOL KillProcessByName(char *szProcessToKill)
{
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;

hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );

if( hProcessSnap == INVALID_HANDLE_VALUE )
  {
    printError( &quot;CreateToolhelp32Snapshot (of processes)&quot; );
    return( FALSE );
  }

pe32.dwSize = sizeof( PROCESSENTRY32 );

if( !Process32First( hProcessSnap, &amp;pe32 ) )
  {
    printError( &quot;Process32First&quot; );  
    CloseHandle( hProcessSnap );     
    return( FALSE );
  }

do{
    if(!strcmp(pe32.szExeFile,szProcessToKill))
    {
    printf(&quot;Prozess: %s \n&quot;,pe32.szExeFile);
    printf(&quot;PID: %d \n&quot;,pe32.th32ProcessID );  
    hProcess = OpenProcess(PROCESS_TERMINATE,0, pe32.th32ProcessID);
    TerminateProcess(hProcess,0);
    CloseHandle(hProcess);
    } 
  } while( Process32Next(hProcessSnap,&amp;pe32) );

CloseHandle( hProcessSnap );
return( TRUE );
}

void printError( TCHAR* msg )
{
  DWORD eNum;
  TCHAR sysMsg[256];
  TCHAR* p;

  eNum = GetLastError( );
  FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
         NULL, eNum,
         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
         sysMsg, 256, NULL );

  // Trim the end of the line and terminate it with a null
  p = sysMsg;
  while( ( *p &gt; 31 ) || ( *p == 9 ) )
    ++p;
  do { *p-- = 0; } while( ( p &gt;= sysMsg ) &amp;&amp;
                          ( ( *p == '.' ) || ( *p &lt; 33 ) ) );

  // Display the message
  printf( &quot;\n  WARNING: %s failed with error %d (%s)&quot;, msg, eNum, sysMsg );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1999140</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1999140</guid><dc:creator><![CDATA[0x33]]></dc:creator><pubDate>Sun, 26 Dec 2010 21:32:03 GMT</pubDate></item></channel></rss>