<?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[[C++]string in system() oder ShellExecute()]]></title><description><![CDATA[<p>Ahoi,<br />
ich habe folgendes Problem: ich möchte einen, via TCP empfangenen, string data mit<br />
data = System::Text::ASCIIEncoding::ASCII-&gt;GetString( bytes, 0, i );<br />
in system() oder Shellexecute() einfügen. Der string enthält ein command, z.B. &lt;C:\\WINDOWS\\system32\\calc.exe&gt; oder &lt;cmd.exe /c ipconfig&gt;. Das Problem ist, das mir der Compiler bei Verwendung von system(data) folgendes ausgibt:<br />
error C2664: 'system': Konvertierung des Parameters 1 von 'System::String ^' in 'const char *' nicht möglich</p>
<p>jemand 'ne Idee zur Beseitigung des Problems?</p>
<p>Gruss</p>
<p>Caldeum</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/237486/c-string-in-system-oder-shellexecute</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 10:28:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/237486.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 29 Mar 2009 16:31:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [C++]string in system() oder ShellExecute() on Sun, 29 Mar 2009 16:31:19 GMT]]></title><description><![CDATA[<p>Ahoi,<br />
ich habe folgendes Problem: ich möchte einen, via TCP empfangenen, string data mit<br />
data = System::Text::ASCIIEncoding::ASCII-&gt;GetString( bytes, 0, i );<br />
in system() oder Shellexecute() einfügen. Der string enthält ein command, z.B. &lt;C:\\WINDOWS\\system32\\calc.exe&gt; oder &lt;cmd.exe /c ipconfig&gt;. Das Problem ist, das mir der Compiler bei Verwendung von system(data) folgendes ausgibt:<br />
error C2664: 'system': Konvertierung des Parameters 1 von 'System::String ^' in 'const char *' nicht möglich</p>
<p>jemand 'ne Idee zur Beseitigung des Problems?</p>
<p>Gruss</p>
<p>Caldeum</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687849</guid><dc:creator><![CDATA[Caldeum]]></dc:creator><pubDate>Sun, 29 Mar 2009 16:31:19 GMT</pubDate></item><item><title><![CDATA[Reply to [C++]string in system() oder ShellExecute() on Sun, 29 Mar 2009 16:34:41 GMT]]></title><description><![CDATA[<p>C++/CLI sogar?</p>
<pre><code class="language-cpp">#include &lt;msclr/marshal_cppstd.h&gt;
//...
System::String ^foo = L&quot;Blablabla...&quot;;
std::string bar = msclr::interop::marshal_as&lt;std::string&gt;(foo);
// und dann:
system(bar.c_str());
</code></pre>
<p>Oder so ähnlich. Hab gad keinen Compiler dabei xD</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687851</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687851</guid><dc:creator><![CDATA[*rant*]]></dc:creator><pubDate>Sun, 29 Mar 2009 16:34:41 GMT</pubDate></item><item><title><![CDATA[Reply to [C++]string in system() oder ShellExecute() on Sun, 29 Mar 2009 16:39:36 GMT]]></title><description><![CDATA[<p>hab leider die marshal_cppstd.h nicht ... ich guck ob ich die wo find</p>
<p>achja: benutze Visual C++ 2008 in Windows Forms</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687853</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687853</guid><dc:creator><![CDATA[Cladeum]]></dc:creator><pubDate>Sun, 29 Mar 2009 16:39:36 GMT</pubDate></item><item><title><![CDATA[Reply to [C++]string in system() oder ShellExecute() on Sun, 29 Mar 2009 16:47:26 GMT]]></title><description><![CDATA[<p>Cladeum schrieb:</p>
<blockquote>
<p>hab leider die marshal_cppstd.h nicht ... ich guck ob ich die wo find</p>
<p>achja: benutze Visual C++ 2008 in Windows Forms</p>
</blockquote>
<p><code>marshal_cppstd.h</code> gibts eventuell nicht in der Express Edition. Aber kein Problem, es ist nur eine Hilfe, es gibt noch etwa ein Dutzend andere Wege. Mit der &quot;alten&quot; Marshal Klasse sieht es so aus:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;

int main()
{
    String ^foo = L&quot;cmd&quot;;
    IntPtr cptr = Marshal::StringToHGlobalAnsi(foo);
    system(static_cast&lt;const char *&gt;(cptr.ToPointer()));
    Marshal::FreeHGlobal(cptr); // Nicht vergessen...
    return 0;
}
</code></pre>
<p><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>E</mi><mi>D</mi><mi>I</mi><mi>T</mi></mrow><annotation encoding="application/x-tex">EDIT</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.05764em;">E</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathit" style="margin-right:0.07847em;">I</span><span class="mord mathit" style="margin-right:0.13889em;">T</span></span></span></span>: Im falschen Forum sind wir trotzdem :p</p>
<p>MfG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687856</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687856</guid><dc:creator><![CDATA[*rant*]]></dc:creator><pubDate>Sun, 29 Mar 2009 16:47:26 GMT</pubDate></item><item><title><![CDATA[Reply to [C++]string in system() oder ShellExecute() on Sun, 29 Mar 2009 16:53:24 GMT]]></title><description><![CDATA[<p>mir ist mit deinem zweiten Quelltext grad nicht ganz klar wie ich dann den Inhalt von data in system() oder ShellExecute() einbetten soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1687864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1687864</guid><dc:creator><![CDATA[Caldeum]]></dc:creator><pubDate>Sun, 29 Mar 2009 16:53:24 GMT</pubDate></item></channel></rss>