<?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[UpdateResource &amp;amp; Strings]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab ein Problem mit dem Hinzufügen/Ändern eines Strings in ner externen Ressource.<br />
Also kurz Suchfunktion genutzt und nen Thread gefunden, wo jmd. genau das selbe Problem hatte:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-82777-and-start-is-0-and-postdays-is-0-and-postorder-is-asc-and-highlight-is-updateresource.html" rel="nofollow">Informationen in andere EXE-Datei schreiben</a></p>
<p>Da der Thread ziemlich alt ist, starte ich hier mal nen neuen...<br />
Wo liegt denn nun genau das Problem?</p>
<p>Hier der Source:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
    HANDLE hUpdateRes;
    BOOL result;
    int an;
    char buff[] = &quot;ein string&quot;;
    wchar_t szBuffer[256];

    an = MultiByteToWideChar(CP_ACP, 0, buff, lstrlen(buff), NULL, 0);
    MultiByteToWideChar(CP_ACP, 0, buff, lstrlen(buff), szBuffer, an);

    hUpdateRes = BeginUpdateResource(&quot;string.exe&quot;, TRUE);
    if(hUpdateRes == NULL)
    {
        MessageBox(NULL, &quot;Datei kann nicht geöffnet werden.&quot;, &quot;Fehler&quot;, MB_OK);
        return 1;
    }

    result = UpdateResource(hUpdateRes, RT_STRING, MAKEINTRESOURCE(101),
                            MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
                            szBuffer, 2*an);
    if(result == FALSE)
    {
        MessageBox(NULL, &quot;Ressource konnte nicht hinzugefuegt werden.&quot;, &quot;Fehler&quot;, MB_OK);
        return 2;
    }

    if(!EndUpdateResource(hUpdateRes, FALSE))
    {
        MessageBox(NULL, &quot;Aenderungen konnten nicht geschrieben werden.&quot;, &quot;Fehler&quot;, MB_OK);
        return 3;
    }

    return 0; 
}
</code></pre>
<p>Und wenn ich's mir dann mit &quot;Resource Hacker&quot; anschaue, kommt das bei raus:</p>
<pre><code>STRINGTABLE
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
{
1600, 	&quot;in string????????????????????????????????????????????????????????????????????????????????????????????&quot;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/201366/updateresource-amp-strings</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 08:29:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/201366.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 28 Dec 2007 22:16:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to UpdateResource &amp;amp; Strings on Fri, 28 Dec 2007 22:16:53 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab ein Problem mit dem Hinzufügen/Ändern eines Strings in ner externen Ressource.<br />
Also kurz Suchfunktion genutzt und nen Thread gefunden, wo jmd. genau das selbe Problem hatte:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-82777-and-start-is-0-and-postdays-is-0-and-postorder-is-asc-and-highlight-is-updateresource.html" rel="nofollow">Informationen in andere EXE-Datei schreiben</a></p>
<p>Da der Thread ziemlich alt ist, starte ich hier mal nen neuen...<br />
Wo liegt denn nun genau das Problem?</p>
<p>Hier der Source:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   PSTR szCmdLine, int iCmdShow)
{
    HANDLE hUpdateRes;
    BOOL result;
    int an;
    char buff[] = &quot;ein string&quot;;
    wchar_t szBuffer[256];

    an = MultiByteToWideChar(CP_ACP, 0, buff, lstrlen(buff), NULL, 0);
    MultiByteToWideChar(CP_ACP, 0, buff, lstrlen(buff), szBuffer, an);

    hUpdateRes = BeginUpdateResource(&quot;string.exe&quot;, TRUE);
    if(hUpdateRes == NULL)
    {
        MessageBox(NULL, &quot;Datei kann nicht geöffnet werden.&quot;, &quot;Fehler&quot;, MB_OK);
        return 1;
    }

    result = UpdateResource(hUpdateRes, RT_STRING, MAKEINTRESOURCE(101),
                            MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
                            szBuffer, 2*an);
    if(result == FALSE)
    {
        MessageBox(NULL, &quot;Ressource konnte nicht hinzugefuegt werden.&quot;, &quot;Fehler&quot;, MB_OK);
        return 2;
    }

    if(!EndUpdateResource(hUpdateRes, FALSE))
    {
        MessageBox(NULL, &quot;Aenderungen konnten nicht geschrieben werden.&quot;, &quot;Fehler&quot;, MB_OK);
        return 3;
    }

    return 0; 
}
</code></pre>
<p>Und wenn ich's mir dann mit &quot;Resource Hacker&quot; anschaue, kommt das bei raus:</p>
<pre><code>STRINGTABLE
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
{
1600, 	&quot;in string????????????????????????????????????????????????????????????????????????????????????????????&quot;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1427445</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1427445</guid><dc:creator><![CDATA[shell]]></dc:creator><pubDate>Fri, 28 Dec 2007 22:16:53 GMT</pubDate></item><item><title><![CDATA[Reply to UpdateResource &amp;amp; Strings on Fri, 28 Dec 2007 23:44:07 GMT]]></title><description><![CDATA[<p>&quot;szBuffer[0]&quot; muß die Anzahl der Zeichen in &quot;buff&quot; enthalten.<br />
Der String ansich darf erst bei &quot;&amp;szBuffer[1]&quot; beginnen.<br />
Anschließend muß die Länge noch korrigiert werden :</p>
<pre><code class="language-cpp">...
// MultiByteToWideChar(CP_ACP, 0, buff, lstrlen(buff), szBuffer, an);
 MultiByteToWideChar(CP_ACP, 0, buff, lstrlen(buff), &amp;szBuffer[1], an);
...
 szBuffer[0] = strlen (buff); // &lt;- fehlt noch
...
 result = UpdateResource(...,2*an+4);
...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1427463</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1427463</guid><dc:creator><![CDATA[echterhacker]]></dc:creator><pubDate>Fri, 28 Dec 2007 23:44:07 GMT</pubDate></item><item><title><![CDATA[Reply to UpdateResource &amp;amp; Strings on Sat, 29 Dec 2007 00:35:48 GMT]]></title><description><![CDATA[<p>Danke, funktioniert <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /><br />
Hätte nicht gedacht, dass ich so schnell ne Antwort bekomme.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1427471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1427471</guid><dc:creator><![CDATA[shell]]></dc:creator><pubDate>Sat, 29 Dec 2007 00:35:48 GMT</pubDate></item></channel></rss>