<?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[char[] nach LPCWSTR  *verzweifel*]]></title><description><![CDATA[<p>hallihallo Gemeinde,</p>
<p>ich verzweifle fast noch an ienem Problem.<br />
Und zwar versuche ich mit ShellExecute ein Programm starten zu lassen.<br />
Der Pfad muss aber vom Typ LPCWSTR sein, liegt aber in char[] vor.</p>
<p>Die große Preisfrage ist nun:<br />
Wie konvertier ich das?</p>
<p>Ich hab mich schon totgegoogelt, aber weiter als bis zur erklärung von MultiByteToWideChar bei msdn.microsoft(die ihc nicht kapiere) komme ich nicht.</p>
<p>Könnt ihr mir helfen?</p>
<p>PS:<br />
char name[] = &quot;Hans&quot;;<br />
LPCWSTR name2;<br />
Wie krieg ich das da rein?... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/213664/char-nach-lpcwstr-verzweifel</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 09:52:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/213664.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 May 2008 11:30:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 11:30:45 GMT]]></title><description><![CDATA[<p>hallihallo Gemeinde,</p>
<p>ich verzweifle fast noch an ienem Problem.<br />
Und zwar versuche ich mit ShellExecute ein Programm starten zu lassen.<br />
Der Pfad muss aber vom Typ LPCWSTR sein, liegt aber in char[] vor.</p>
<p>Die große Preisfrage ist nun:<br />
Wie konvertier ich das?</p>
<p>Ich hab mich schon totgegoogelt, aber weiter als bis zur erklärung von MultiByteToWideChar bei msdn.microsoft(die ihc nicht kapiere) komme ich nicht.</p>
<p>Könnt ihr mir helfen?</p>
<p>PS:<br />
char name[] = &quot;Hans&quot;;<br />
LPCWSTR name2;<br />
Wie krieg ich das da rein?... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512978</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512978</guid><dc:creator><![CDATA[Quellcode]]></dc:creator><pubDate>Tue, 20 May 2008 11:30:45 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 11:43:32 GMT]]></title><description><![CDATA[<p>in C++: reinterpreteCast.<br />
Ic C:</p>
<pre><code>name2 = ((LPCWSTR) name)
</code></pre>
<p>oder so ähnlich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512986</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512986</guid><dc:creator><![CDATA[Elektronix]]></dc:creator><pubDate>Tue, 20 May 2008 11:43:32 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 11:43:19 GMT]]></title><description><![CDATA[<p>Quellcode schrieb:</p>
<blockquote>
<p>hallihallo Gemeinde,</p>
<p>ich verzweifle fast noch an ienem Problem.<br />
Und zwar versuche ich mit ShellExecute ein Programm starten zu lassen.<br />
Der Pfad muss aber vom Typ LPCWSTR sein, liegt aber in char[] vor.</p>
<p>Die große Preisfrage ist nun:<br />
Wie konvertier ich das?</p>
<p>Ich hab mich schon totgegoogelt, aber weiter als bis zur erklärung von MultiByteToWideChar bei msdn.microsoft(die ihc nicht kapiere) komme ich nicht.</p>
<p>Könnt ihr mir helfen?</p>
<p>PS:<br />
char name[] = &quot;Hans&quot;;<br />
LPCWSTR name2;<br />
Wie krieg ich das da rein?... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
</blockquote>
<pre><code class="language-cpp">LPCWSTR name2 = L&quot;Hans&quot;;
</code></pre>
<p>? <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1512987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512987</guid><dc:creator><![CDATA[sothis_]]></dc:creator><pubDate>Tue, 20 May 2008 11:43:19 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 11:44:34 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>du solltest dich entscheiden ob du Multibyte oder Unicode schreiben willst. Das ist das blöde an den ganzen Tutorials im Internet, die sind alle Multibyte aber die MSVC bei neuen Projekten Unicode vorgibt.</p>
<p>Das bedeutet das du bei Unicode anstatt char TCHAR verwenden solltest. Von dieser ShellExecute und all den anderen Winapi Funktion gibt es nämlich W und A Funktion wobei W für Unicode ist. In der Programmierung soweit ohne Bedeutung da die Einstellung des Zeichensatzes das übernimmt. Also anstatt ShellExecuteW() einfach ShellExecute() aber dann mit TCHAR wenn Unicode, wenn jedoch Multibyte dann mit char</p>
<p>Also unter Unicode</p>
<p>TCHAR name[] = TEXT(&quot;bla&quot;);<br />
ShellExecute(name);</p>
<p>Ob Unicode oder Multibyte kannst du in den Projekteinstellungen ändern, irgendwas mit Zeichensatz.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512990</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512990</guid><dc:creator><![CDATA[5z4g]]></dc:creator><pubDate>Tue, 20 May 2008 11:44:34 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 11:45:12 GMT]]></title><description><![CDATA[<p>Elektronix schrieb:</p>
<blockquote>
<p>in C++: reinterpreteCast.<br />
Ic C:</p>
<pre><code>name2 = ((LPCWSTR) name)
</code></pre>
<p>oder so ähnlich.</p>
</blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/11581">@Elektronix</a>: Und was erwartest Du denn nach der Anweisung?</p>
<p>Ich schätze mal, dieser Code ergibt nicht das gewünschte Verhalten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1512991</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1512991</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Tue, 20 May 2008 11:45:12 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 11:56:53 GMT]]></title><description><![CDATA[<p>Hab das mal ausprobiert mit TCHAR...<br />
sieht dann wie folgt aus:</p>
<pre><code class="language-cpp">TCHAR name[] = TEXT(op2);
</code></pre>
<p>ist dann folgendes:</p>
<p>'Lop2': nichtdeklarierter Bezeichner</p>
<p>Was zur Höll ist Lop2, ihc hab das nie deklariert oder dergleichen..<br />
kommentiere ich die Zeile aus, komm tder fehler nicht...</p>
<p>achja op2 ist:</p>
<pre><code class="language-cpp">char op2[256]
</code></pre>
<p>Und wie nun weiter?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1513001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1513001</guid><dc:creator><![CDATA[Quellcode]]></dc:creator><pubDate>Tue, 20 May 2008 11:56:53 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 12:04:52 GMT]]></title><description><![CDATA[<p>Zu:<br />
LPCWSTR str = ((LPCWSTR)name);</p>
<p>Der Compiler meckert nicht mehr, aber es funktioniert nicht, wenn ich str<br />
in ShellExecute verwende (er macht gar nichts).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1513007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1513007</guid><dc:creator><![CDATA[Quellcode]]></dc:creator><pubDate>Tue, 20 May 2008 12:04:52 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 12:12:22 GMT]]></title><description><![CDATA[<p>Quellcode schrieb:</p>
<blockquote>
<p>Zu:<br />
LPCWSTR str = ((LPCWSTR)name);</p>
<p>Der Compiler meckert nicht mehr, aber es funktioniert nicht, wenn ich str<br />
in ShellExecute verwende (er macht gar nichts).</p>
</blockquote>
<p>Siehe mein letzter Post.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1513015</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1513015</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Tue, 20 May 2008 12:12:22 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 12:14:48 GMT]]></title><description><![CDATA[<p>und was mach ich nun?</p>
<p>Ich will das unbedingt umwandeln...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1513019</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1513019</guid><dc:creator><![CDATA[Quellcode]]></dc:creator><pubDate>Tue, 20 May 2008 12:14:48 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 12:26:44 GMT]]></title><description><![CDATA[<p>In der FAQ gibts ein Thread (der Code befindet sich ziemlich unten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-161855.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-161855.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1513036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1513036</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Tue, 20 May 2008 12:26:44 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 12:48:07 GMT]]></title><description><![CDATA[<p>Die Funktion ShellExecute erwartet unter Multibyte ein LPCTSTR unter Unicode aber einen LPCWSTR. Wenn du einen pfad zu einer Datei hast dann schreibst du den ja in einer variable, also einen char arry.</p>
<p>Wenn deine IDE bei ShellExecute einen LPCWSTR haben will, dann steht dein projekt auf Unicode weil ShellExecute an ShellExecuteW weiterleitet .. so ausgedrückt.</p>
<p>Entweder packst du die Daten in TCHARs anstatt chars oder du stellt dein projekt auf Multibyte. Mit Multibyte leitet deine IDE an ShellExecuteA weiter die deinen char (LPCTSTR ) schluckt.</p>
<p>Unicode:<br />
TCHAR sDateipfad[] = TEXT(&quot;c:\\meineanwendung.exe&quot;);<br />
ShellExecute( ..., sDateipfad, ...); // Leitet an ShellExecuteW weiter</p>
<p>Multibyte:<br />
char sDateipfad[] = &quot;c:\\meineanwendung.exe&quot;; // oder _T(&quot;&quot;) oder doch mit TEXT(&quot;&quot;) .. ka</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1513048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1513048</guid><dc:creator><![CDATA[5z4g]]></dc:creator><pubDate>Tue, 20 May 2008 12:48:07 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 13:40:50 GMT]]></title><description><![CDATA[<p>Ich hab mein Problem gelöst....<br />
Anstelle von ShellExecute hab ich einfach ShellExecuteA genommen und mein<br />
char *pathname =&quot;blablabla&quot; auf LPCSTR path gelegt.</p>
<p>SO geht jetzt alles...<br />
Mensch, der schöne Tag is schon halb rum... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> scheiss ehrgeiz</p>
<p>EDIT: grad mitbekommen, dass es auch ohne LPCSTR path geht...</p>
<p>Danke allen, dir ihre zeit geopfert haben, mir bei meinem Problem zu helfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1513099</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1513099</guid><dc:creator><![CDATA[Quellcode]]></dc:creator><pubDate>Tue, 20 May 2008 13:40:50 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Tue, 20 May 2008 13:46:14 GMT]]></title><description><![CDATA[<blockquote>
<p>scheiss ehrgeiz</p>
</blockquote>
<p>Naja, soviel ehrgeiz ist da nicht drin, denn es gibt schon schwierigkeiten bei der Unicode Variante.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1513107</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1513107</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Tue, 20 May 2008 13:46:14 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Thu, 22 May 2008 15:05:48 GMT]]></title><description><![CDATA[<p>Quellcode schrieb:</p>
<blockquote>
<p>Hab das mal ausprobiert mit TCHAR...<br />
sieht dann wie folgt aus:</p>
<pre><code class="language-cpp">TCHAR name[] = TEXT(op2);
</code></pre>
<p>ist dann folgendes:</p>
<p>'Lop2': nichtdeklarierter Bezeichner</p>
<p>Was zur Höll ist Lop2, ihc hab das nie deklariert oder dergleichen..<br />
kommentiere ich die Zeile aus, komm tder fehler nicht...</p>
<p>achja op2 ist:</p>
<pre><code class="language-cpp">char op2[256]
</code></pre>
<p>Und wie nun weiter?</p>
</blockquote>
<p>TEXT is einfach nur ein Makro:</p>
<pre><code class="language-cpp">#define __TEXT(quote) L##quote
</code></pre>
<p>D.h. es setzt einfach ein L vor die &quot;&quot;.. Und wenn du nun op2 übergibst ensteht natürlich Lop2. Das Makro is auch nur für String-Literale gedacht, nich für Variablen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1514379</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1514379</guid><dc:creator><![CDATA[pyromania]]></dc:creator><pubDate>Thu, 22 May 2008 15:05:48 GMT</pubDate></item><item><title><![CDATA[Reply to char[] nach LPCWSTR  *verzweifel* on Thu, 22 May 2008 16:22:40 GMT]]></title><description><![CDATA[<p>achso...</p>
<p>naja muss man halt erstmal wissen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1514423</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1514423</guid><dc:creator><![CDATA[Quellcode]]></dc:creator><pubDate>Thu, 22 May 2008 16:22:40 GMT</pubDate></item></channel></rss>