<?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[Datei aus DLL extrahieren geht nicht?]]></title><description><![CDATA[<p>Aloha,</p>
<p>in einer meiner DLL's habe ich ein kleines Problem mit dem Extrahieren<br />
einer Ressource (PDF-Dokument) aus einem Menüpunkt.</p>
<p>Das PDF wurde unter &quot;PDF&quot; als IDR_PDF1 eingebunden und wird auch in den<br />
Temp-Pfad des Systemes geschrieben. Jedoch mit einer Größe von 0Byte.</p>
<p>Nehme ich den gleichen Code in einer Exe, so wird alles korrekt geschrieben<br />
und die Datei kann auch geöffnet werden...</p>
<p>Hat jemand eine Idee warum es in einer MFC-Dll nicht geht?</p>
<pre><code class="language-cpp">CString ls_path;
GetTempPath(100,   ls_path.GetBuffer(MAX_PATH));   
ls_path.ReleaseBuffer(); 

HINSTANCE hApp = ::GetModuleHandle(0); 
ASSERT(hApp); 

HRSRC hResInfo; 
hResInfo = ::FindResource(hApp,MAKEINTRESOURCE(IDR_PDF1),TEXT(&quot;PDF&quot;)); 
HGLOBAL hRes = ::LoadResource(hApp, hResInfo);

BYTE *PROG = (LPBYTE)::LockResource(hRes); 
int PROG_SIZE = SizeofResource(hApp,hResInfo);

CFile OutFile; 
ls_path+=&quot;x.pdf&quot;;
OutFile.Open(ls_path,OF_CREATE|OF_WRITE,NULL); 
OutFile.Write(PROG,PROG_SIZE); 
OutFile.Close();

CString info=&quot;Die Anleitung wurde in den temporären Ordner unter\n&quot;;
info+=ls_path;
info+=&quot;\nentpackt und wird nun geöffnet.&quot;;
MessageBox(info,&quot;Hinweis:&quot;,MB_ICONINFORMATION);

ShellExecute(NULL, &quot;open&quot;, ls_path, NULL, NULL, SW_SHOW);
</code></pre>
<p>Die Fehlermeldung lautet:</p>
<p>Adobe Reader konnte &quot;x.pdf&quot; nicht öffnen, da der Dateityp nicht unterstützt<br />
wird, oder die Datei beschädigt ist....</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182961/datei-aus-dll-extrahieren-geht-nicht</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 05:37:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182961.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 31 May 2007 06:37:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Datei aus DLL extrahieren geht nicht? on Thu, 31 May 2007 06:37:02 GMT]]></title><description><![CDATA[<p>Aloha,</p>
<p>in einer meiner DLL's habe ich ein kleines Problem mit dem Extrahieren<br />
einer Ressource (PDF-Dokument) aus einem Menüpunkt.</p>
<p>Das PDF wurde unter &quot;PDF&quot; als IDR_PDF1 eingebunden und wird auch in den<br />
Temp-Pfad des Systemes geschrieben. Jedoch mit einer Größe von 0Byte.</p>
<p>Nehme ich den gleichen Code in einer Exe, so wird alles korrekt geschrieben<br />
und die Datei kann auch geöffnet werden...</p>
<p>Hat jemand eine Idee warum es in einer MFC-Dll nicht geht?</p>
<pre><code class="language-cpp">CString ls_path;
GetTempPath(100,   ls_path.GetBuffer(MAX_PATH));   
ls_path.ReleaseBuffer(); 

HINSTANCE hApp = ::GetModuleHandle(0); 
ASSERT(hApp); 

HRSRC hResInfo; 
hResInfo = ::FindResource(hApp,MAKEINTRESOURCE(IDR_PDF1),TEXT(&quot;PDF&quot;)); 
HGLOBAL hRes = ::LoadResource(hApp, hResInfo);

BYTE *PROG = (LPBYTE)::LockResource(hRes); 
int PROG_SIZE = SizeofResource(hApp,hResInfo);

CFile OutFile; 
ls_path+=&quot;x.pdf&quot;;
OutFile.Open(ls_path,OF_CREATE|OF_WRITE,NULL); 
OutFile.Write(PROG,PROG_SIZE); 
OutFile.Close();

CString info=&quot;Die Anleitung wurde in den temporären Ordner unter\n&quot;;
info+=ls_path;
info+=&quot;\nentpackt und wird nun geöffnet.&quot;;
MessageBox(info,&quot;Hinweis:&quot;,MB_ICONINFORMATION);

ShellExecute(NULL, &quot;open&quot;, ls_path, NULL, NULL, SW_SHOW);
</code></pre>
<p>Die Fehlermeldung lautet:</p>
<p>Adobe Reader konnte &quot;x.pdf&quot; nicht öffnen, da der Dateityp nicht unterstützt<br />
wird, oder die Datei beschädigt ist....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1295683</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1295683</guid><dc:creator><![CDATA[Faki]]></dc:creator><pubDate>Thu, 31 May 2007 06:37:02 GMT</pubDate></item><item><title><![CDATA[Reply to Datei aus DLL extrahieren geht nicht? on Thu, 31 May 2007 06:43:59 GMT]]></title><description><![CDATA[<p>das liegt an ::GetModuleHandle(0)</p>
<blockquote>
<p>lpModuleName</p>
<p>If this parameter is NULL, GetModuleHandle returns a handle to the file used to create the calling process (.exe file).</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1295686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1295686</guid><dc:creator><![CDATA[........]]></dc:creator><pubDate>Thu, 31 May 2007 06:43:59 GMT</pubDate></item><item><title><![CDATA[Reply to Datei aus DLL extrahieren geht nicht? on Thu, 31 May 2007 06:57:09 GMT]]></title><description><![CDATA[<p>Juhu, vielen Dank. Hätte man auch selbst über die MSDN sehen müssen...<br />
Mit dem Namen der DLL (&quot;mydll.dll&quot;) geht es nun.</p>
<p>Thx,<br />
Faki</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1295694</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1295694</guid><dc:creator><![CDATA[Faki]]></dc:creator><pubDate>Thu, 31 May 2007 06:57:09 GMT</pubDate></item><item><title><![CDATA[Reply to Datei aus DLL extrahieren geht nicht? on Thu, 31 May 2007 07:13:50 GMT]]></title><description><![CDATA[<p>Warum machten alle immer mit GetModuleHandle herum? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Jede DLL bekommt Ihr eigenes Handle beim Aufruf über DllMain mitgeteilt!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1295703</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1295703</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Thu, 31 May 2007 07:13:50 GMT</pubDate></item><item><title><![CDATA[Reply to Datei aus DLL extrahieren geht nicht? on Thu, 31 May 2007 08:25:51 GMT]]></title><description><![CDATA[<p>Ich habe doch gar keine DllMain <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1295739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1295739</guid><dc:creator><![CDATA[Faki]]></dc:creator><pubDate>Thu, 31 May 2007 08:25:51 GMT</pubDate></item><item><title><![CDATA[Reply to Datei aus DLL extrahieren geht nicht? on Thu, 31 May 2007 08:57:48 GMT]]></title><description><![CDATA[<p>Faki schrieb:</p>
<blockquote>
<p>Ich habe doch gar keine DllMain <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>Doch hast Du! Jede DLL die Code ausführt hat eine!</p>
<p>Und wenn es die MFC ist gibt es immer noch AfxGetInstanceHandle!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1295757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1295757</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Thu, 31 May 2007 08:57:48 GMT</pubDate></item></channel></rss>