<?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[System geht ShellExecute nicht]]></title><description><![CDATA[<p>Hallo ich möchte ein Programm schreiben, dass den Standardgateway ermitteln soll, und dann entsprechend Netzlaufwerke verbinden. Ich habe nun versucht den Standardgateway mittels ipconfig zu ermitteln und in ein File zu schreiben. Das Prolbem ist nun, folgende Methode funktioniert:</p>
<pre><code class="language-cpp">system(&quot;ipconfig /all &gt; test.txt&quot;);
</code></pre>
<p>dies hingegen nicht</p>
<pre><code class="language-cpp">ShellExecute(NULL,&quot;open&quot;,&quot;ipconfig&quot;,&quot;/all &gt; text.txt&quot;,ExtractFilePath(Application-&gt;ExeName).c_str(),SW_NORMAL);
</code></pre>
<p>Wie krieg ich dass mit ShellExecute hin, damit die ausgabe in das Textfile erfolgt? Oder hat jemand noch ne viel einfachere Möglichkeit den Standardgateway zu ermitteln?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/121100/system-geht-shellexecute-nicht</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Jul 2026 00:59:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/121100.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 19 Sep 2005 21:16:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to System geht ShellExecute nicht on Mon, 19 Sep 2005 21:16:36 GMT]]></title><description><![CDATA[<p>Hallo ich möchte ein Programm schreiben, dass den Standardgateway ermitteln soll, und dann entsprechend Netzlaufwerke verbinden. Ich habe nun versucht den Standardgateway mittels ipconfig zu ermitteln und in ein File zu schreiben. Das Prolbem ist nun, folgende Methode funktioniert:</p>
<pre><code class="language-cpp">system(&quot;ipconfig /all &gt; test.txt&quot;);
</code></pre>
<p>dies hingegen nicht</p>
<pre><code class="language-cpp">ShellExecute(NULL,&quot;open&quot;,&quot;ipconfig&quot;,&quot;/all &gt; text.txt&quot;,ExtractFilePath(Application-&gt;ExeName).c_str(),SW_NORMAL);
</code></pre>
<p>Wie krieg ich dass mit ShellExecute hin, damit die ausgabe in das Textfile erfolgt? Oder hat jemand noch ne viel einfachere Möglichkeit den Standardgateway zu ermitteln?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/876150</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/876150</guid><dc:creator><![CDATA[wedmer]]></dc:creator><pubDate>Mon, 19 Sep 2005 21:16:36 GMT</pubDate></item><item><title><![CDATA[Reply to System geht ShellExecute nicht on Tue, 20 Sep 2005 05:40:52 GMT]]></title><description><![CDATA[<p>siehe FAQ</p>
]]></description><link>https://www.c-plusplus.net/forum/post/876229</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/876229</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Tue, 20 Sep 2005 05:40:52 GMT</pubDate></item><item><title><![CDATA[Reply to System geht ShellExecute nicht on Tue, 20 Sep 2005 07:38:34 GMT]]></title><description><![CDATA[<p>Tipp:<br />
Programm: cmd<br />
Parameter: /k ipconfig /all &gt; text.txt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/876296</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/876296</guid><dc:creator><![CDATA[Muesly]]></dc:creator><pubDate>Tue, 20 Sep 2005 07:38:34 GMT</pubDate></item><item><title><![CDATA[Reply to System geht ShellExecute nicht on Tue, 20 Sep 2005 11:30:48 GMT]]></title><description><![CDATA[<p>wenn ich cmd als Programm benutze, funktionierts. liegt es daran, dass meine erste Variante mit ShellExectue nicht funktioniert hat, da &quot;<em>&gt; test.txt</em>&quot; ein Parameter von cmd ist und nicht von ipconfig? Weil wenn ich bloss</p>
<pre><code class="language-cpp">ShellExecute(0,&quot;open&quot;,&quot;ipconfig&quot;,&quot;/all&quot;,0,SW_HIDE)
</code></pre>
<p>aufrufe, ohne das Textfile funktioniert es ja auch.</p>
<p>Wie kann ich jetzt den cmd Prozess wieder beenden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/876504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/876504</guid><dc:creator><![CDATA[wedmer]]></dc:creator><pubDate>Tue, 20 Sep 2005 11:30:48 GMT</pubDate></item><item><title><![CDATA[Reply to System geht ShellExecute nicht on Tue, 20 Sep 2005 12:15:44 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>du bekommst von ShellExecute den Prozeßhandle als Rückgabewert.<br />
Den kannst du mit TerminateProcess() benutzen, um den prozeß wieer zu beenden.</p>
<p>/Edit : Und natürlich solltest du den Rückgabewert von ShellExecute erstmal auf einen Fehlercode überprüfen. Siehe MSDN.<br />
Außerdem sollte dir mittlerweile auffallen, das das in das WinAPI-Forum gehört.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/876560</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/876560</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Tue, 20 Sep 2005 12:15:44 GMT</pubDate></item><item><title><![CDATA[Reply to System geht ShellExecute nicht on Tue, 20 Sep 2005 20:56:29 GMT]]></title><description><![CDATA[<p>Ups, ja hast recht, habe mich im Forum vertan, vielleicht kann ja ein mod diesen Thread verschieben.</p>
<p>Ok, habe mal folgendes probiert, kalpt leider nicht:</p>
<pre><code class="language-cpp">int TForm1::ReadIpconfig(AnsiString txtFile,TStringList* IpconfigInfo)
{
   unsigned long ExitCode;
   HINSTANCE CmdHandle;
   AnsiString CmdLine = &quot;/k ipconfig /all &gt; &quot;+txtFile;
   AnsiString Directory = ExtractFilePath(Application-&gt;ExeName);
   CmdHandle  = ShellExecute(NULL,&quot;open&quot;,&quot;cmd&quot;,
                             CmdLine.c_str(),
                             Directory.c_str(),
                             SW_NORMAL);
   if((int)CmdHandle &lt; 32)
   {
      MessageBox(NULL,SysErrorMessage(GetLastError()).c_str(),
                 &quot;Error&quot;,MB_OK|MB_ICONERROR);
      return 0;
   }
   else;
   do
   {
      GetExitCodeProcess(CmdHandle,&amp;ExitCode);
   }
   while(ExitCode == STILL_ACTIVE);
   if(!TerminateProcess(CmdHandle,ExitCode))
   {
:arrow_right:    MessageBox(NULL,SysErrorMessage(GetLastError()).c_str(),
                 &quot;Error&quot;,MB_OK|MB_ICONERROR);
      return 0;
   }
   else;

   IpconfigInfo-&gt;LoadFromFile(&quot;test.txt&quot;);
   return 1;
}
</code></pre>
<p>kriege bei der mit &quot;<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    />&quot; markierten Stelle den Fehler Code <strong>Ungültiges Handle</strong> zurück</p>
]]></description><link>https://www.c-plusplus.net/forum/post/876660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/876660</guid><dc:creator><![CDATA[wedmer]]></dc:creator><pubDate>Tue, 20 Sep 2005 20:56:29 GMT</pubDate></item><item><title><![CDATA[Reply to System geht ShellExecute nicht on Tue, 20 Sep 2005 21:07:12 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>hm... also laut MSDN sollte es gehen</p>
<blockquote>
<p>If the function succeeds, the return value is the instance handle of the application that was run, or the handle of a dynamic data exchange (DDE) server application.</p>
</blockquote>
<p>Aber du kannst ja auch ShellExecuteEx nehmen. Dort bekommst du auf jedenfall einen gültigen Handle.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/876668</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/876668</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Tue, 20 Sep 2005 21:07:12 GMT</pubDate></item><item><title><![CDATA[Reply to System geht ShellExecute nicht on Tue, 20 Sep 2005 21:40:03 GMT]]></title><description><![CDATA[<p>Habe mal folgende Zeilen versucht, jetzt erhalte ich die Fehlermeldung <strong>Zugriff verweigert</strong></p>
<pre><code class="language-cpp">unsigned long ExitCode;
   HINSTANCE CmdHandle;
   AnsiString CmdLine = &quot;/k ipconfig /all &gt; &quot;+ExtractFileName(txtFile);

   SHELLEXECUTEINFO ShellInfo;
   ShellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
   ShellInfo.lpVerb = &quot;open&quot;;
   ShellInfo.lpFile = &quot;cmd&quot;;
   ShellInfo.lpParameters = CmdLine.c_str();
   ShellInfo.lpDirectory = ExtractFilePath(txtFile).c_str();
   ShellInfo.nShow = SW_HIDE;

   if(!ShellExecuteEx(&amp;ShellInfo))
   {
      MessageBox(Application-&gt;Handle,SysErrorMessage(GetLastError()).c_str(),
                 &quot;Error&quot;,MB_OK|MB_ICONERROR);
      return 0;
   }
   else;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/876680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/876680</guid><dc:creator><![CDATA[wedmer]]></dc:creator><pubDate>Tue, 20 Sep 2005 21:40:03 GMT</pubDate></item></channel></rss>