<?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[DLL-Resource statisch einbinden]]></title><description><![CDATA[<p>Hallo,<br />
ich bräuchte mal Eure Hilfe.</p>
<p>Ich lade ein Icon aus einer DLL dynamisch. Das Icon wird als Bild angezeigt:</p>
<pre><code class="language-cpp">__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner){
TIcon *icon = new Graphics::TIcon;
HINSTANCE hinstDLL=LoadLibrary(&quot;dynamischeDLL.dll&quot;);

  if (hinstDLL != 0){
    Form1-&gt;Caption = &quot;DLL wurde geladen&quot;;
    icon-&gt;Handle=LoadImage(hinstDLL,&quot;ICON_0&quot;, IMAGE_ICON, 64,64, LR_DEFAULTSIZE);
    Image1-&gt;Canvas-&gt;Draw(1,1,icon); //Image1 im OI erstellt
  }
  FreeLibrary(hinstDLL);
  delete icon;
}
</code></pre>
<p><strong>Aber, wie geht das mit einer statischen Einbindung?</strong> <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>Eine LIB-Datei habe ich von meiner DLL mit IMPLIB.EXE auf DOS-Ebene erstellt und in das Projekt eingefügt.<br />
Ich habe 'mal eine Version als statisch gebastelt, siehe unten. Leider wird damit kein Bild angezeigt. Ich glaube der Fehler liegt in HINSTANCE. Ich weiß nicht, was ich dieser Variablen zuweisen soll? Kann jemand helfen?</p>
<pre><code class="language-cpp">__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner){
TIcon *icon = new Graphics::TIcon;
HINSTANCE hinstDLL; //das ist sicher falsch, ich weiß nicht, was ich hier hinstDLL zuweisen soll!!
  if (hinstDLL != 0){
    Form1-&gt;Caption = &quot;DLL wurde geladen&quot;;
    icon-&gt;Handle=LoadImage(hinstDLL,&quot;ICON_0&quot;, IMAGE_ICON, 64,64, LR_DEFAULTSIZE);
    Image1-&gt;Canvas-&gt;Draw(1,1,icon); //Image1 im OI erstellt
  }
  delete icon;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/195095/dll-resource-statisch-einbinden</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 09:27:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/195095.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 14 Oct 2007 07:52:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Sun, 14 Oct 2007 07:52:58 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich bräuchte mal Eure Hilfe.</p>
<p>Ich lade ein Icon aus einer DLL dynamisch. Das Icon wird als Bild angezeigt:</p>
<pre><code class="language-cpp">__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner){
TIcon *icon = new Graphics::TIcon;
HINSTANCE hinstDLL=LoadLibrary(&quot;dynamischeDLL.dll&quot;);

  if (hinstDLL != 0){
    Form1-&gt;Caption = &quot;DLL wurde geladen&quot;;
    icon-&gt;Handle=LoadImage(hinstDLL,&quot;ICON_0&quot;, IMAGE_ICON, 64,64, LR_DEFAULTSIZE);
    Image1-&gt;Canvas-&gt;Draw(1,1,icon); //Image1 im OI erstellt
  }
  FreeLibrary(hinstDLL);
  delete icon;
}
</code></pre>
<p><strong>Aber, wie geht das mit einer statischen Einbindung?</strong> <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>Eine LIB-Datei habe ich von meiner DLL mit IMPLIB.EXE auf DOS-Ebene erstellt und in das Projekt eingefügt.<br />
Ich habe 'mal eine Version als statisch gebastelt, siehe unten. Leider wird damit kein Bild angezeigt. Ich glaube der Fehler liegt in HINSTANCE. Ich weiß nicht, was ich dieser Variablen zuweisen soll? Kann jemand helfen?</p>
<pre><code class="language-cpp">__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner){
TIcon *icon = new Graphics::TIcon;
HINSTANCE hinstDLL; //das ist sicher falsch, ich weiß nicht, was ich hier hinstDLL zuweisen soll!!
  if (hinstDLL != 0){
    Form1-&gt;Caption = &quot;DLL wurde geladen&quot;;
    icon-&gt;Handle=LoadImage(hinstDLL,&quot;ICON_0&quot;, IMAGE_ICON, 64,64, LR_DEFAULTSIZE);
    Image1-&gt;Canvas-&gt;Draw(1,1,icon); //Image1 im OI erstellt
  }
  delete icon;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1384735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384735</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Sun, 14 Oct 2007 07:52:58 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Sun, 14 Oct 2007 09:35:48 GMT]]></title><description><![CDATA[<p>thunderbol4 schrieb:</p>
<blockquote>
<p>Leider wird damit kein Bild angezeigt. Ich glaube der Fehler liegt in HINSTANCE. Ich weiß nicht, was ich dieser Variablen zuweisen soll?</p>
</blockquote>
<pre><code class="language-cpp">GetModuleHandle (&quot;statischeDLL.dll&quot;)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1384758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384758</guid><dc:creator><![CDATA[audacia]]></dc:creator><pubDate>Sun, 14 Oct 2007 09:35:48 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Sun, 14 Oct 2007 14:08:53 GMT]]></title><description><![CDATA[<p>Hallo <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8276">@audacia</a>:</p>
<p>habe das 'mal für die statische Variante probiert:</p>
<pre><code class="language-cpp">__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner){
TIcon *icon = new Graphics::TIcon;
HMODULE hmoduleDLL=GetModuleHandle(&quot;statischeDLL.dll&quot;);
  if (hmoduleDLL != 0){
    Form1-&gt;Caption = &quot;DLL wurde geladen.&quot;;
    icon-&gt;Handle=LoadImage(hmoduleDLL,&quot;ICON_0&quot;, IMAGE_ICON, 64, 64, LR_DEFAULTSIZE);
    Image1-&gt;Canvas-&gt;Draw(1,1,icon);
  };
  delete icon;
}
</code></pre>
<p><strong>Leider noch kein Erfolg.</strong> Der Debugger zeigt mir für <strong>hmoduleDLL</strong> den Wert NULL an.</p>
<p>Mit dem Hexeditor habe ich mir die LIB-Datei näher angeschaut (Hatte ich mit implib.exe aus der DLL erzeugt).<br />
1. Die Größe der LIB-Datei ist nur 1 kB. Im Vergleich dazu hat die DLL-Datei 82 kB.<br />
2. Die LIB-Datei besteht fast nur aus OOh, 3 oder 4 Bytes haben einen zählbaren Wert.</p>
<p>Ist das normal? <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="😕"
    /><br />
Wenn der Code oben okay ist, kann's eigentlich nur daran liegen oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384911</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384911</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Sun, 14 Oct 2007 14:08:53 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Sun, 14 Oct 2007 15:21:31 GMT]]></title><description><![CDATA[<p>thunderbol4 schrieb:</p>
<blockquote>
<p>Wenn der Code oben okay ist, kann's eigentlich nur daran liegen oder?</p>
</blockquote>
<p>Vermutlich ja. Ob die .LIB-Datei korrekt ist, kannst du mit TDUMP herausfinden. Wenn sie fehlerhaft ist, solltest du evtl. mal ein wenig mit den Optionen von IMPLIB herumprobieren (oder, wenn du C++Builder 2007 hast, IMPLIB32 verwenden).</p>
<p>Falls du die DLL selbst kompilierst, erstellt dir der Linker übrigens gleich die passende .LIB-Datei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1384965</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1384965</guid><dc:creator><![CDATA[audacia]]></dc:creator><pubDate>Sun, 14 Oct 2007 15:21:31 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Mon, 15 Oct 2007 22:19:43 GMT]]></title><description><![CDATA[<p>Hallo <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8276">@audacia</a>:<br />
bin leider immer noch auf Fehlersuche.</p>
<pre><code class="language-cpp">HMODULE hmoduleDLL=GetModuleHandle(&quot;statischeDLL.dll&quot;);
</code></pre>
<p>ergibt immer noch NULL. <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="😞"
    /></p>
<p>Bin auf Deinen Vorschlag eingegangen und habe mit meinem Builder6 mit DLL-Experten ein DLL-Projekt erstellt Dort habe ich eine Icon-Resource als RC-Datei eingebunden. Nach der Compilierung und dem Linken hatte ich eine LIB- und DLL-Datei erhalten. Die LIB-Datei schien diesmal in Ordnung (? <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="😕"
    /> ?). Sie war immerhin auf 10kB angewachsen (vorher 1kB).<br />
Mit meinem PEResourceExplorer (Programm zur Bearbeitung von Resourcen) konnte ich an der fertigen DLL keine Fehler entdecken. Die Icons waren so eingebaut, wie in der RC-Datei festgelegt.</p>
<p>Stehe vor einem Rätsel.<br />
Woran kann man erkennen, dass die LIB-Datei okay ist?<br />
Andererseits kann ich auch nicht verstehen, weshalb ich bei <strong>GetModuleHandle</strong> immer noch NULL erhalte. Woran kann das denn liegen? Mit <strong>LoadLibrary</strong> klappt das doch auch?!</p>
<p>Vielleicht hast Du ja noch eine Idee, trotzdem schon 'mal Dank für Deine Bemühungen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1385988</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1385988</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Mon, 15 Oct 2007 22:19:43 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Tue, 16 Oct 2007 09:50:12 GMT]]></title><description><![CDATA[<p>Hallo thunderbol4,</p>
<p>wenn</p>
<pre><code class="language-cpp">GetModuleHandle(&quot;statischeDLL.dll&quot;)
</code></pre>
<p>NULL zurückgibt schau dir mal den Fehler mit</p>
<pre><code class="language-cpp">DWORD GetLastError(VOID)
</code></pre>
<p>an.</p>
<p>Gruß<br />
Peter</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386198</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386198</guid><dc:creator><![CDATA[Peter24]]></dc:creator><pubDate>Tue, 16 Oct 2007 09:50:12 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Tue, 16 Oct 2007 22:57:21 GMT]]></title><description><![CDATA[<p>Hallo <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16191">@Peter24</a>:</p>
<p>Habe das 'mal probiert:</p>
<pre><code class="language-cpp">HMODULE hmoduleDLL=GetModuleHandle(&quot;statischeDLL.dll&quot;);	
if (hmoduleDLL != 0){ ... }
else{
  int fehler = GetLastError();
  Form1-&gt;Caption = &quot;DLL nicht gefunden &quot; + IntToStr(fehler);
}
</code></pre>
<p>Der Fehler hat die Nummer: <strong>126</strong><br />
Im Google deutet alles daraufhin, dass er das DLL-Modul nicht findet.(oder vielleicht LIB- ??).<br />
Versteh ich nicht! Alle Dateien befinden sich im Projektverzeichnis. Habe die Verzeichnisoptionen und Dateinamen geprüft. Die sind auch okay.</p>
<p>Habe mit einem Tool die DLL ein bißchen näher untersucht, kann aber nicht sagen, ob die so okay ist:</p>
<p>*Turbo Dump Version 5.0.16.12 Copyright (c) 1988, 2000 Inprise Corporation<br />
Display of File D:\..\DLL STATISCH\STATISCHEDLL.DLL</p>
<p>IMPORT: rtl60.bpl<br />
IMPORT: rtl60.bpl<br />
IMPORT: rtl60.bpl<br />
IMPORT: rtl60.bpl<br />
IMPORT: rtl60.bpl<br />
IMPORT: rtl60.bpl<br />
IMPORT: rtl60.bpl<br />
IMPORT: rtl60.bpl<br />
IMPORT: BORLNDMM.DLL<br />
IMPORT: KERNEL32.DLL<br />
IMPORT: CC3260MT.DLL*</p>
<p>und für die LIB-Datei zeigt mir das Tool nur Folgendes an:</p>
<p>*Publics by module</p>
<p>statischeDLL size = 0<br />
___CPPdebugHook*</p>
<p>Vielleicht gibt's noch einen Hinweis?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1386773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1386773</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Tue, 16 Oct 2007 22:57:21 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Wed, 17 Oct 2007 10:33:34 GMT]]></title><description><![CDATA[<p>Wenn du eine statische Bibliothek in deinem Programm eingebunden hast, dann kannst du natürlich nicht nach einer DLL (&quot;Dynamic Link Library&quot;) suchen lassen.</p>
<p>Der Funktion 'LoadImage' mußt du dann einfach das Instanz-Handle deiner Applikation zuweisen (s. WinMain) bzw. probiere einfach mal NULL aus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1387025</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1387025</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Wed, 17 Oct 2007 10:33:34 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Wed, 17 Oct 2007 12:26:18 GMT]]></title><description><![CDATA[<p>Th schrieb:</p>
<blockquote>
<p>Wenn du eine statische Bibliothek in deinem Programm eingebunden hast, dann kannst du natürlich nicht nach einer DLL (&quot;Dynamic Link Library&quot;) suchen lassen.</p>
</blockquote>
<p>Soweit ich das verstanden habe, hat er eine DLL statisch eingebunden.</p>
<p>Das Anwengungs-Modul ist erhältlich über GetModuleHandle (NULL).</p>
<p>Btw, der Fehlercode 126 lautet im Klartext &quot;The specified module could not be found&quot;. Wie genau gehst du denn vor beim Einbinden der DLL?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1387146</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1387146</guid><dc:creator><![CDATA[audacia]]></dc:creator><pubDate>Wed, 17 Oct 2007 12:26:18 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Wed, 17 Oct 2007 13:32:34 GMT]]></title><description><![CDATA[<p>Eine DLL kann man NICHT statisch einbinden, sondern nur eine Bibliothek (Lib).<br />
Daher kann mittels GetModuleHandle() ja auch kein Modul 'xxx.dll' im laufenden Prozess gefunden werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1387226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1387226</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Wed, 17 Oct 2007 13:32:34 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Wed, 17 Oct 2007 13:40:59 GMT]]></title><description><![CDATA[<p>Th schrieb:</p>
<blockquote>
<p>Eine DLL kann man NICHT statisch einbinden</p>
</blockquote>
<p>Ist dir dann der Begriff &quot;statisch linken&quot; genehm? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Schau dir doch einfach die Beschreibung seines Vorgehens an, da wird das deutlich.</p>
<p>thunderbol4 schrieb:</p>
<blockquote>
<p>Bin auf Deinen Vorschlag eingegangen und habe mit meinem Builder6 mit DLL-Experten ein DLL-Projekt erstellt Dort habe ich eine Icon-Resource als RC-Datei eingebunden. Nach der Compilierung und dem Linken hatte ich eine LIB- und DLL-Datei erhalten. Die LIB-Datei schien diesmal in Ordnung (? <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="😕"
    /> ?). Sie war immerhin auf 10kB angewachsen (vorher 1kB).</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1387236</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1387236</guid><dc:creator><![CDATA[audacia]]></dc:creator><pubDate>Wed, 17 Oct 2007 13:40:59 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Wed, 17 Oct 2007 19:36:47 GMT]]></title><description><![CDATA[<p>Hallo <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/9348">@Th</a>, hallo <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8276">@audacia</a></p>
<p>Grundlage für mein Vorgehen war das hier:<br />
<a href="http://www.marquardtnet.info/cecke/tutorials.8/8_dll.html" rel="nofollow">http://www.marquardtnet.info/cecke/tutorials.8/8_dll.html</a></p>
<p>*Die statische DLL nutzen:<br />
Im C++Builder &quot;Projekt -&gt; Dem Projekt hinzufügen&quot; auswählen<br />
Die zu der DLL gehörende *.lib Datei hinzufügen<br />
In dem Modul, welches die DLL-Funktionen oder Klassen benutzt die zur DLL gehörende <em>.h Datei einbinden</em><br />
( <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="😕"
    /> habe keine *.h bei der Erzeugung der DLL bekommen, da es sich hier um eine reine Resourcendatei handelt <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="😕"
    /> )<br />
<em>Alle Funkionen der DLL stehen zur Verfügung<br />
Die DLL muß entweder im Verzeichnis der Applikation, im Windows/System/-Verzeichnis oder in einem Verzeichnis liegen,<br />
welches in der Umgebungsvariablen PATH enthalten ist.<br />
Fertig</em></p>
<p>Genauso habe ich es dann gemacht:<br />
Die Projektdatei zur Erzeugung der DLL und LIB<br />
ProjectGroup1<br />
|<br />
statischeDLL.dll<br />
|_ statischeDLL.res<br />
|_ statischeDLL.bpf<br />
|_ Unit1.cpp<br />
|_ MeineIcons.rc</p>
<p>Die Projektdatei für die EXE (soll Icons laden und dazu die DLL nutzen...)<br />
ProjectGroup1<br />
|<br />
Project1.exe<br />
|_Project1.res<br />
|_Project1.cpp<br />
|_Unit1.cpp<br />
|_statischeDLL.lib</p>
<p><strong>Gibt's noch einen Anstoß? So schnell möchte ich eigentlich nicht aufgeben <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="😃"
    /></strong></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1387444</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1387444</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Wed, 17 Oct 2007 19:36:47 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Thu, 18 Oct 2007 07:32:33 GMT]]></title><description><![CDATA[<p>Hallo thunderbol4,</p>
<p>Wie es aussieht hast Du die DLL richtig eingebunden.<br />
Ich vermute mal das die DLL nicht geladen wird da sie keine Funktionen exportiert.<br />
Pack doch mal ein Funktion in die DLL die z.B. eine MessageBox mit dem Text &quot;Hallo DLL&quot; bringt.<br />
Wenn Du die Funktion im Programm aufrufen kannst dann weisst Du das die DLL geladen wurde und dann kannst Du mit Sicherheit auch auf die Resourcen zugreifen.</p>
<p>Gruß Peter</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1387627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1387627</guid><dc:creator><![CDATA[Peter24]]></dc:creator><pubDate>Thu, 18 Oct 2007 07:32:33 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Thu, 18 Oct 2007 10:24:42 GMT]]></title><description><![CDATA[<p>Hallo <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16191">@Peter24</a>:<br />
daran hatte ich auch schon gedacht. Werde mal eine dummy-Funktion einbauen und melde mich zum Ergebnis was passiert ist</p>
<p>Bis dann</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1387762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1387762</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Thu, 18 Oct 2007 10:24:42 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Resource statisch einbinden on Thu, 18 Oct 2007 18:46:39 GMT]]></title><description><![CDATA[<p>Vielen Dank <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16191">@Peter24</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8276">@audacia</a> u <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/9348">@Th</a></p>
<p>wie von <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/16191">@Peter24</a> vorgeschlagen <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="👍"
    /> , habe ich die kleine Anwendung mit einer dummy-Funktion in der DLL-Datei durchgespielt.<br />
Siehe da, meine Icon's werden jetzt angezeigt <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="🙂"
    /> . Auch mit der statischen DLL!<br />
Die dummy-Funktion muss allerdings im EXE-Projekt aufgerufen werden. Sie nur zu deklarieren reicht scheinbar nicht.</p>
<pre><code class="language-cpp">//DLL-Projekt, i d d Icon-Resource eingebunden wird
#include &lt;vcl.h&gt;
#include &lt;windows.h&gt;
#pragma hdrstop

// Funktion für Export deklarieren
extern &quot;C&quot; __declspec(dllexport) int dummy(int);

#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
  return 1;
}

// dummy Funktion
int dummy(int i){return i+i}
</code></pre>
<pre><code class="language-cpp">//EXE-Projekt
#include &lt;vcl.h&gt;
#pragma hdrstop
#include &quot;Unit1.h&quot;
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;

// Funktion aus der DLL importieren
extern &quot;C&quot; __declspec(dllimport) int dummy(int);

__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner){
TIcon *icon = new Graphics::TIcon;
HMODULE hmoduleDLL=GetModuleHandle(&quot;statischeDLL.dll&quot;);
  if (hmoduleDLL != 0){
    Form1-&gt;Caption = &quot;DLL wurde geladen.&quot;;
    icon-&gt;Handle=LoadImage(hmoduleDLL,&quot;ICON_1&quot;, IMAGE_ICON, 32,32, LR_DEFAULTSIZE);
    ImageList1-&gt;AddIcon(icon);
    Image1-&gt;Canvas-&gt;Draw(1,1,icon);
  }
  else{
    int fehler = GetLastError();
    Form1-&gt;Caption = &quot;DLL nicht gefunden &quot;+ IntToStr(fehler);
  }
  delete icon;
  int j=dummy(0);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1388137</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1388137</guid><dc:creator><![CDATA[thunderbol4]]></dc:creator><pubDate>Thu, 18 Oct 2007 18:46:39 GMT</pubDate></item></channel></rss>