<?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[Problem mit BeginUpdateResource()]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich habe mir ein DLL Projekt erstellt, in dem ein Dialog als Resource vorhanden ist. In einem anderen Projekt soll diese Resource dann dynamisch geladen werden.</p>
<p>Dazu hab ich folgenden Quellcode aus der MSDN genommen:</p>
<pre><code class="language-cpp">LPVOID hResLoad;     // handle to loaded resource 
HANDLE hExe;        // handle to existing .EXE file 
HRSRC hRes;         // handle/ptr. to res. info. in hExe 
HINSTANCE hUpdateRes;  // update resource handle 
char *lpResLock;    // pointer to resource data 
BOOL result; 
// Load the .EXE file that contains the dialog box you want to copy. 
hExe = LoadLibrary(&quot;hand.exe&quot;); 
if (hExe == NULL) 
{ 
    ErrorHandler(&quot;Could not load exe.&quot;); 
} 

// Locate the dialog box resource in the .EXE file. 
hRes = FindResource(hExe, &quot;AboutBox&quot;, RT_DIALOG); 
if (hRes == NULL) 
{ 
    ErrorHandler(&quot;Could not locate dialog box.&quot;); 
} 

// Load the dialog box into global memory. 
hResLoad = LoadResource(hExe, hRes); 
if (hResLoad == NULL) 
{ 
    ErrorHandler(&quot;Could not load dialog box.&quot;); 
} 

// Lock the dialog box into global memory. 
lpResLock = LockResource(hResLoad); 
if (lpResLock == NULL) 
{ 
    ErrorHandler(&quot;Could not lock dialog box.&quot;); 
} 

// Open the file to which you want to add the dialog box resource. 
hUpdateRes = BeginUpdateResource(&quot;foot.exe&quot;, FALSE); 
if (hUpdateRes == NULL) 
{ 
    ErrorHandler(&quot;Could not open file for writing.&quot;); 
} 

// Add the dialog box resource to the update list. 
result = UpdateResource(hUpdateRes,       // update resource handle 
     RT_DIALOG,                   // change dialog box resource 
     &quot;AboutBox&quot;,                  // dialog box name 
     MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),  // neutral language
     lpResLock,                   // ptr to resource info 
     SizeofResource(hExe, hRes)); // size of resource info. 
if (result == FALSE) 
{ 
    ErrorHandler(&quot;Could not add resource.&quot;); 
} 

// Write changes to FOOT.EXE and then close it. 
if (!EndUpdateResource(hUpdateRes, FALSE)) 
{ 
    ErrorHandler(&quot;Could not write changes to file.&quot;); 
} 

// Clean up. 
if (!FreeLibrary(hExe)) 
{ 
    ErrorHandler(&quot;Could not free executable.&quot;); 
}
</code></pre>
<p>Funktionieren tut das auch in soweit, dass er keine Fehler beim Kompilieren meldet und auch starten tut. Problem ist die Funktion BeginUpdateResource, die mir den Dialog zu meiner Anwendung hinzufügen soll.</p>
<p>Er muss die Datei wohl zum schreiben öffnen, was er aber nicht kann, weil die Anwendung ja schon gestartet ist.</p>
<p>Wie mache ich das dann, dass er mir trotzdem die Resource hinzufügt? Der eigentliche Hintergrund soll praktisch nichts anderes sein, als wenn ich in einer normalen Anwendung ein DoModal(); zum Dialogaufrufen ausführe.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/161900/problem-mit-beginupdateresource</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 11:40:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/161900.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Oct 2006 09:34:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit BeginUpdateResource() on Thu, 12 Oct 2006 09:34:16 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich habe mir ein DLL Projekt erstellt, in dem ein Dialog als Resource vorhanden ist. In einem anderen Projekt soll diese Resource dann dynamisch geladen werden.</p>
<p>Dazu hab ich folgenden Quellcode aus der MSDN genommen:</p>
<pre><code class="language-cpp">LPVOID hResLoad;     // handle to loaded resource 
HANDLE hExe;        // handle to existing .EXE file 
HRSRC hRes;         // handle/ptr. to res. info. in hExe 
HINSTANCE hUpdateRes;  // update resource handle 
char *lpResLock;    // pointer to resource data 
BOOL result; 
// Load the .EXE file that contains the dialog box you want to copy. 
hExe = LoadLibrary(&quot;hand.exe&quot;); 
if (hExe == NULL) 
{ 
    ErrorHandler(&quot;Could not load exe.&quot;); 
} 

// Locate the dialog box resource in the .EXE file. 
hRes = FindResource(hExe, &quot;AboutBox&quot;, RT_DIALOG); 
if (hRes == NULL) 
{ 
    ErrorHandler(&quot;Could not locate dialog box.&quot;); 
} 

// Load the dialog box into global memory. 
hResLoad = LoadResource(hExe, hRes); 
if (hResLoad == NULL) 
{ 
    ErrorHandler(&quot;Could not load dialog box.&quot;); 
} 

// Lock the dialog box into global memory. 
lpResLock = LockResource(hResLoad); 
if (lpResLock == NULL) 
{ 
    ErrorHandler(&quot;Could not lock dialog box.&quot;); 
} 

// Open the file to which you want to add the dialog box resource. 
hUpdateRes = BeginUpdateResource(&quot;foot.exe&quot;, FALSE); 
if (hUpdateRes == NULL) 
{ 
    ErrorHandler(&quot;Could not open file for writing.&quot;); 
} 

// Add the dialog box resource to the update list. 
result = UpdateResource(hUpdateRes,       // update resource handle 
     RT_DIALOG,                   // change dialog box resource 
     &quot;AboutBox&quot;,                  // dialog box name 
     MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),  // neutral language
     lpResLock,                   // ptr to resource info 
     SizeofResource(hExe, hRes)); // size of resource info. 
if (result == FALSE) 
{ 
    ErrorHandler(&quot;Could not add resource.&quot;); 
} 

// Write changes to FOOT.EXE and then close it. 
if (!EndUpdateResource(hUpdateRes, FALSE)) 
{ 
    ErrorHandler(&quot;Could not write changes to file.&quot;); 
} 

// Clean up. 
if (!FreeLibrary(hExe)) 
{ 
    ErrorHandler(&quot;Could not free executable.&quot;); 
}
</code></pre>
<p>Funktionieren tut das auch in soweit, dass er keine Fehler beim Kompilieren meldet und auch starten tut. Problem ist die Funktion BeginUpdateResource, die mir den Dialog zu meiner Anwendung hinzufügen soll.</p>
<p>Er muss die Datei wohl zum schreiben öffnen, was er aber nicht kann, weil die Anwendung ja schon gestartet ist.</p>
<p>Wie mache ich das dann, dass er mir trotzdem die Resource hinzufügt? Der eigentliche Hintergrund soll praktisch nichts anderes sein, als wenn ich in einer normalen Anwendung ein DoModal(); zum Dialogaufrufen ausführe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1153310</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1153310</guid><dc:creator><![CDATA[MSS-Software]]></dc:creator><pubDate>Thu, 12 Oct 2006 09:34:16 GMT</pubDate></item></channel></rss>