<?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-Befehl mit Variablen]]></title><description><![CDATA[<p>Hallo, ich hab zwar schon gesucht und etwas gefunden, allerdings hilft das nicht wirklich viel weiter. Also ich habe bei einem Client ein Edit-Feld, wo man eine Zeit eingeben kann für das &quot;shutdown -t zeit&quot;<br />
Das soll dann beim Server in einer Variable gespeichert werden und dann bei system eingebunden werden:</p>
<p>Client:</p>
<pre><code class="language-cpp">// SendMessage 
void __fastcall TForm1::btnSendClick(TObject *Sender) 
{ 
  Client-&gt;Socket-&gt;SendText(&quot;TXTM&quot; + edNachricht-&gt;Text); // TXTM = TextMessage 
} 
//--------------------------------------------------------------------------- 
// COM Shutdown 
void __fastcall TForm1::btnShutdownClick(TObject *Sender) 
{ 
  Client-&gt;Socket-&gt;SendText(&quot;COM1shutdown -t &quot; + Edit1-&gt;Text + &quot; -s&quot;); 
} 
//---------------------------------------------------------------------------
</code></pre>
<p>Server:</p>
<pre><code class="language-cpp">/ On Client Read, Messages und Befehle ausführen/auswerten 
void __fastcall TForm1::ServerClientRead(TObject *Sender, 
      TCustomWinSocket *Socket) 
{ 
  AnsiString RecText = Socket-&gt;ReceiveText(); 
  int leng = RecText.Length();                // Länge des Strings speichern 
  AnsiString header = RecText.SubString(1, 3);    // Die ersten 3 Chars als 
                                                  // Header kopieren 
  AnsiString rest = RecText.SubString(5, leng);   // Ab dem 5. Char ist es Rest 
  AnsiString index = RecText.SubString(4, 1);      // Den index holen 
  if (header == &quot;COM&quot;)                            // Header vergleichen für COM 
  { 
      // 1 = shutdown 
      if (index == &quot;1&quot;) 
      { 
         char rest[25]; 
         system(rest); 
      } 
  } 
  if (header == &quot;TXT&quot;)                            // Header vergleichen für TXT 
      ShowMessage(rest);
</code></pre>
<p>TextMessage wird erfolgreich angezeigt, allerdings wird ja wie sonst auch immer, der Shutdown-Befehl nicht ausgeführt. Weiß einer, woran es liegen könnte?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/122735/system-befehl-mit-variablen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Jul 2026 01:08:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/122735.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 09 Oct 2005 12:00:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to System-Befehl mit Variablen on Sun, 09 Oct 2005 12:00:01 GMT]]></title><description><![CDATA[<p>Hallo, ich hab zwar schon gesucht und etwas gefunden, allerdings hilft das nicht wirklich viel weiter. Also ich habe bei einem Client ein Edit-Feld, wo man eine Zeit eingeben kann für das &quot;shutdown -t zeit&quot;<br />
Das soll dann beim Server in einer Variable gespeichert werden und dann bei system eingebunden werden:</p>
<p>Client:</p>
<pre><code class="language-cpp">// SendMessage 
void __fastcall TForm1::btnSendClick(TObject *Sender) 
{ 
  Client-&gt;Socket-&gt;SendText(&quot;TXTM&quot; + edNachricht-&gt;Text); // TXTM = TextMessage 
} 
//--------------------------------------------------------------------------- 
// COM Shutdown 
void __fastcall TForm1::btnShutdownClick(TObject *Sender) 
{ 
  Client-&gt;Socket-&gt;SendText(&quot;COM1shutdown -t &quot; + Edit1-&gt;Text + &quot; -s&quot;); 
} 
//---------------------------------------------------------------------------
</code></pre>
<p>Server:</p>
<pre><code class="language-cpp">/ On Client Read, Messages und Befehle ausführen/auswerten 
void __fastcall TForm1::ServerClientRead(TObject *Sender, 
      TCustomWinSocket *Socket) 
{ 
  AnsiString RecText = Socket-&gt;ReceiveText(); 
  int leng = RecText.Length();                // Länge des Strings speichern 
  AnsiString header = RecText.SubString(1, 3);    // Die ersten 3 Chars als 
                                                  // Header kopieren 
  AnsiString rest = RecText.SubString(5, leng);   // Ab dem 5. Char ist es Rest 
  AnsiString index = RecText.SubString(4, 1);      // Den index holen 
  if (header == &quot;COM&quot;)                            // Header vergleichen für COM 
  { 
      // 1 = shutdown 
      if (index == &quot;1&quot;) 
      { 
         char rest[25]; 
         system(rest); 
      } 
  } 
  if (header == &quot;TXT&quot;)                            // Header vergleichen für TXT 
      ShowMessage(rest);
</code></pre>
<p>TextMessage wird erfolgreich angezeigt, allerdings wird ja wie sonst auch immer, der Shutdown-Befehl nicht ausgeführt. Weiß einer, woran es liegen könnte?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888116</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888116</guid><dc:creator><![CDATA[milo51]]></dc:creator><pubDate>Sun, 09 Oct 2005 12:00:01 GMT</pubDate></item><item><title><![CDATA[Reply to System-Befehl mit Variablen on Sun, 09 Oct 2005 12:05:38 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Was soll denn das hier</p>
<pre><code class="language-cpp">char rest[25];
system(rest);
</code></pre>
<p>Du erzeugst hier ein neues Array und übergibst es dann an system. Da steht ja nichts drin und somit wird auch nichts ausgeführt.<br />
evtl.</p>
<pre><code class="language-cpp">if (header == &quot;COM&quot;)                            // Header vergleichen für COM
  {
      // 1 = shutdown
      if (index == &quot;1&quot;)
      {
         system(rest.c_str());
      }
  }
</code></pre>
<p>In rest muss aber ein gültiges Kommando stehen.</p>
<p>Ciao</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888118</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Sun, 09 Oct 2005 12:05:38 GMT</pubDate></item><item><title><![CDATA[Reply to System-Befehl mit Variablen on Sun, 09 Oct 2005 12:42:01 GMT]]></title><description><![CDATA[<p>Hehe geil danke! Endlich mal^^ Super.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888146</guid><dc:creator><![CDATA[milo51]]></dc:creator><pubDate>Sun, 09 Oct 2005 12:42:01 GMT</pubDate></item><item><title><![CDATA[Reply to System-Befehl mit Variablen on Sun, 09 Oct 2005 19:57:09 GMT]]></title><description><![CDATA[<p>hm und warum funktioniert das jetzt nicht?</p>
<pre><code class="language-cpp">AnsiString path = ExtractFilePath(Application-&gt;ExeName);
  system(&quot;copy &quot; + path.c_str()) + &quot; C:\\Windows\\system32&quot;);
</code></pre>
<p>Fehler:<br />
[C++ Fehler] Unit1.cpp(16): E2085 Unzulässige Zeigeraddition</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888415</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888415</guid><dc:creator><![CDATA[milo51]]></dc:creator><pubDate>Sun, 09 Oct 2005 19:57:09 GMT</pubDate></item><item><title><![CDATA[Reply to System-Befehl mit Variablen on Sun, 09 Oct 2005 20:31:26 GMT]]></title><description><![CDATA[<p>Dein &quot;copy &quot; ist ein einfaches char-Array, und das kennt nun mal keinen Additions-Operator. Was du brauchst ist eine Stringklasse wie AnsiString, oder <em>strcpy()</em>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/888434</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/888434</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Sun, 09 Oct 2005 20:31:26 GMT</pubDate></item><item><title><![CDATA[Reply to System-Befehl mit Variablen on Tue, 11 Oct 2005 07:37:30 GMT]]></title><description><![CDATA[<p>*args*</p>
<p>zum runterfahren verwende lieber direkt die WinAPI und keinen klotz wie <strong>system</strong>.</p>
<p>siehe:</p>
<p><strong>InitiateSystemShutdown</strong>, <strong>AbortSystemShutdown</strong>, <strong>ExitWindows</strong> und <strong>ExitWindowsEx</strong></p>
]]></description><link>https://www.c-plusplus.net/forum/post/889343</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/889343</guid><dc:creator><![CDATA[Sunday]]></dc:creator><pubDate>Tue, 11 Oct 2005 07:37:30 GMT</pubDate></item><item><title><![CDATA[Reply to System-Befehl mit Variablen on Wed, 12 Oct 2005 14:42:24 GMT]]></title><description><![CDATA[<p>Kannst du mir dann mal erklären, wie ich die Befehle benutze?<br />
Weil wenn ich das in der Hilfe eingebe, bekomme ich keine Ergebnisse.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890729</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890729</guid><dc:creator><![CDATA[milo51]]></dc:creator><pubDate>Wed, 12 Oct 2005 14:42:24 GMT</pubDate></item><item><title><![CDATA[Reply to System-Befehl mit Variablen on Wed, 12 Oct 2005 15:55:04 GMT]]></title><description><![CDATA[<p>Das kann er bestimmt erklären, aber nicht in diesem Thread und nicht in diesem Forum.</p>
<p>milo51 schrieb:</p>
<blockquote>
<p>Weil wenn ich das in der Hilfe eingebe, bekomme ich keine Ergebnisse.</p>
</blockquote>
<p><a href="http://www.junix.ch/bcb/help/hilfe.html" rel="nofollow">http://www.junix.ch/bcb/help/hilfe.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/890786</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890786</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Wed, 12 Oct 2005 15:55:04 GMT</pubDate></item><item><title><![CDATA[Reply to System-Befehl mit Variablen on Wed, 12 Oct 2005 15:56:29 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Wozu gibt es denn die MSDN<br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/initiatesystemshutdown.asp" rel="nofollow">InitiateSystemShutdown</a><br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/abortsystemshutdown.asp" rel="nofollow">AbortSystemShutdown</a><br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/exitwindows.asp" rel="nofollow">ExitWindows</a><br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/exitwindowsex.asp" rel="nofollow">ExitWindowsEx</a></p>
<p>Ciao</p>
]]></description><link>https://www.c-plusplus.net/forum/post/890789</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/890789</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 12 Oct 2005 15:56:29 GMT</pubDate></item></channel></rss>