<?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 erstellen]]></title><description><![CDATA[<p>Hallo,</p>
<p>Also ich bin gerade dabei, meine erste dll zu erstellen. Und zwar habe ich ein C++ Projekt mit ein paar klassen und würde diese gerne in ein C# (GUI) Projekt einbinden. Da man anscheinend keine klassen dirket einbinden kann, schreibe ich neue Methoden, damit ich die bestehenden Klassen verwenden kann. Mein Problem ist, dass ich auf eine Methode von einer bestehenden Klasse zugreifen will, ich aber folgende Fehlermeldung bekommen:</p>
<pre><code>Error 1	error C2352: illegal call of non-static member function
</code></pre>
<p>Nun hätte ich auch versucht meine Methode + den Variablen auf static zu setzen, hat auch nicht funktioniert.</p>
<p>mein C++ Code (h-file):</p>
<pre><code>#include &quot;meineganzenKlasse.h&quot;

#ifndef __MEINE_DLL_H__
#define __MEINE_DLL_H__ 

#ifdef __cplusplus 
extern &quot;C&quot; {__declspec(dllexport)

#endif
	// Entry point into the dynamic-link library (DLL)
	 BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved); // Here are my exported DLL functions

__declspec(dllexport) void WINAPI start_game();
__declspec(dllexport) void WINAPI set_Parameter(int, int, int, int);

#ifdef __cplusplus 

}
#endif

#endif /* __MEINE_DLL_H__ */
</code></pre>
<p>mein C++ Code (cpp- File):</p>
<pre><code>#include &quot;meineDLL.h&quot;
#include &lt;windows.h&gt;

//-------------DLLMAIN------------------------------------------
extern BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) 
{
	switch (dwReason) 
	{
		case DLL_PROCESS_ATTACH: // Code to run when the DLL is loaded
			break; 
		case DLL_PROCESS_DETACH: // Code to run when the DLL is freed 
			break; 
		case DLL_THREAD_ATTACH: // Code to run when a thread is created // during the DLL's lifetime 
			break; 
		case DLL_THREAD_DETACH: // Code to run when a thread ends normally. 
			break; 
	} // everything fine 

	return TRUE; 
}

//eigene Methoden von einer anderen klasse aufrufen: 
extern  void WINAPI start_game() 
{ 

	meineKlasse::eineMethode();	 //dies Funktioniert
}

extern void WINAPI set_Parameter(int _a, int _b, int _c, int _d)
{

  meineKlasse::meineMethode(_a, _b, _c, _d); //hier bekomme ich meine    
                                               Fehlermeldung
}
</code></pre>
<pre><code>meineKlasse.h
static void meineMehode(int, int, int, int);

meineKlasse.cpp
void meineKlasse::meineMethode(int _a, int _b, int _c, int _d)
{
  x=_a;
//usw.

}
</code></pre>
<p>Wäre sper wenn mir jemand weiterhelfen könnte.<br />
LG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/230132/dll-erstellen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 02:48:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/230132.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 21 Dec 2008 11:59:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL erstellen on Sun, 21 Dec 2008 11:59:53 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Also ich bin gerade dabei, meine erste dll zu erstellen. Und zwar habe ich ein C++ Projekt mit ein paar klassen und würde diese gerne in ein C# (GUI) Projekt einbinden. Da man anscheinend keine klassen dirket einbinden kann, schreibe ich neue Methoden, damit ich die bestehenden Klassen verwenden kann. Mein Problem ist, dass ich auf eine Methode von einer bestehenden Klasse zugreifen will, ich aber folgende Fehlermeldung bekommen:</p>
<pre><code>Error 1	error C2352: illegal call of non-static member function
</code></pre>
<p>Nun hätte ich auch versucht meine Methode + den Variablen auf static zu setzen, hat auch nicht funktioniert.</p>
<p>mein C++ Code (h-file):</p>
<pre><code>#include &quot;meineganzenKlasse.h&quot;

#ifndef __MEINE_DLL_H__
#define __MEINE_DLL_H__ 

#ifdef __cplusplus 
extern &quot;C&quot; {__declspec(dllexport)

#endif
	// Entry point into the dynamic-link library (DLL)
	 BOOL WINAPI DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved); // Here are my exported DLL functions

__declspec(dllexport) void WINAPI start_game();
__declspec(dllexport) void WINAPI set_Parameter(int, int, int, int);

#ifdef __cplusplus 

}
#endif

#endif /* __MEINE_DLL_H__ */
</code></pre>
<p>mein C++ Code (cpp- File):</p>
<pre><code>#include &quot;meineDLL.h&quot;
#include &lt;windows.h&gt;

//-------------DLLMAIN------------------------------------------
extern BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) 
{
	switch (dwReason) 
	{
		case DLL_PROCESS_ATTACH: // Code to run when the DLL is loaded
			break; 
		case DLL_PROCESS_DETACH: // Code to run when the DLL is freed 
			break; 
		case DLL_THREAD_ATTACH: // Code to run when a thread is created // during the DLL's lifetime 
			break; 
		case DLL_THREAD_DETACH: // Code to run when a thread ends normally. 
			break; 
	} // everything fine 

	return TRUE; 
}

//eigene Methoden von einer anderen klasse aufrufen: 
extern  void WINAPI start_game() 
{ 

	meineKlasse::eineMethode();	 //dies Funktioniert
}

extern void WINAPI set_Parameter(int _a, int _b, int _c, int _d)
{

  meineKlasse::meineMethode(_a, _b, _c, _d); //hier bekomme ich meine    
                                               Fehlermeldung
}
</code></pre>
<pre><code>meineKlasse.h
static void meineMehode(int, int, int, int);

meineKlasse.cpp
void meineKlasse::meineMethode(int _a, int _b, int _c, int _d)
{
  x=_a;
//usw.

}
</code></pre>
<p>Wäre sper wenn mir jemand weiterhelfen könnte.<br />
LG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633537</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633537</guid><dc:creator><![CDATA[Planetasia]]></dc:creator><pubDate>Sun, 21 Dec 2008 11:59:53 GMT</pubDate></item><item><title><![CDATA[Reply to DLL erstellen on Sun, 21 Dec 2008 12:08:35 GMT]]></title><description><![CDATA[<p>Das geht deshalb nicht, weil Du der Funktion eine Instanz der Klasse übergeben musst. Die taucht zwar nicht explizit in der Parameterliste auf, wird aber übergeben.<br />
Du könntest die Funktion vielleicht so schreiben:</p>
<pre><code class="language-cpp">void set_Parameter(meineKlasse* cls, int _a, int _b, int _c, int _d)
{
   cls.meineMethode(_a, _b, _c, _d);
}
</code></pre>
<p>Dann kannst Du von C# aus einen IntPtr auf die Klasse übergeben.</p>
<p>Dann noch was: &quot;WINAPI&quot; vor der Funktion klingt irgendwie komisch. Normal steht da so etwas wie DLLEXPORT oder so ähnlich vor. Habe aber gerade keinen eigenen Quellcode zum Nachgucken hier.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633542</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633542</guid><dc:creator><![CDATA[Wirdbald]]></dc:creator><pubDate>Sun, 21 Dec 2008 12:08:35 GMT</pubDate></item><item><title><![CDATA[Reply to DLL erstellen on Sun, 21 Dec 2008 12:27:13 GMT]]></title><description><![CDATA[<p>Danke Wirdbald, so hat's 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="👍"
    /></p>
<p>bezüglich dem &quot;WINAPI&quot; ich hab mittlerweile einige unterschiedliche &quot;Schlüsselwörter&quot; gefunden, der Unterschied ist mir allerdings nicht klar, ich habe bloß einen Tipp von einem Bekannten bekommen und verwende deswegen WINAPI.<br />
Sollte dies falsch sein, bitte kurz bescheid sagen und wenn möglich kurz erklären warum es falsch ist.</p>
<p>Lg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633547</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633547</guid><dc:creator><![CDATA[Planetasia]]></dc:creator><pubDate>Sun, 21 Dec 2008 12:27:13 GMT</pubDate></item><item><title><![CDATA[Reply to DLL erstellen on Sun, 21 Dec 2008 19:05:38 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-14199.html" rel="nofollow">Phoemuex</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-15.html" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-4.html" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1633739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1633739</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Sun, 21 Dec 2008 19:05:38 GMT</pubDate></item></channel></rss>