<?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-Funktionen nicht gefunden]]></title><description><![CDATA[<p>Hi, ich hab ne DLL geschrieben, die 2 Funktionen hat:</p>
<p>EXPORT BOOL CALLBACK OnInitialize(HWND);<br />
EXPORT BOOL CALLBACK OnShutdown(void);</p>
<p>Im Programm versuch ich darauf zuzugreifen, aber meine Messageboxen sagen immer wieder, dass die Funktionen nicht gefunden werden können. Warum? Ich habe mein altes Projekt nur überarbeitet (neue VS C++ Version) und schon gehts nich mehr oder was?</p>
<p>Header der DLL</p>
<pre><code class="language-cpp">#ifdef __cplusplus
#define EXPORT extern &quot;C&quot; __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif

EXPORT BOOL CALLBACK OnInitialize(HWND);
EXPORT BOOL CALLBACK OnShutdown(void);
</code></pre>
<p>Source der DLL</p>
<pre><code class="language-cpp">HINSTANCE   hDllInstance;

int APIENTRY DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
    switch (fdwReason)
	{
        case DLL_PROCESS_ATTACH :
            hDllInstance = hInstance ;
            break ;
    }  
    return TRUE ;
}

EXPORT BOOL CALLBACK OnInitialize(HWND hwnd)
{
//Funktionssource...
}

EXPORT BOOL CALLBACK OnShutdown()
{
//Funktionssource...
}
</code></pre>
<p>Hier der Source des Testprojekts für die DLL:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;commctrl.h&gt;
#include &lt;commdlg.h&gt;

#define WINDOW_WIDTH	640
#define WINDOW_HEIGHT	480

#pragma warning(disable : 4996 )
#pragma comment(lib, &quot;comctl32.lib&quot;)

typedef bool(*ONINITIALIZE)(HWND hParent);
typedef bool (*ONSHUTDOWN)();

ONINITIALIZE Initialize = NULL;
ONSHUTDOWN Shutdown = NULL;

HMODULE hLibrary;

LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);

TCHAR CurrentKey;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
{
	HWND hwnd;
	MSG msg;
	WNDCLASSEX wcx;

	InitCommonControls();

	wcx.hInstance = hInstance;
	wcx.lpszClassName = L&quot;KeyTestClass&quot;;
	wcx.lpfnWndProc = WindowProcedure;
	wcx.style = CS_DBLCLKS;
	wcx.cbSize = sizeof(WNDCLASSEX);
	wcx.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
	wcx.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
	wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcx.lpszMenuName = NULL;
	wcx.cbClsExtra = 0;
	wcx.cbWndExtra = 0;
	wcx.hbrBackground = (HBRUSH) COLOR_BTNSHADOW;

	RegisterClassEx(&amp;wcx);

	//Hauptfenster
	hwnd = CreateWindowEx(0, 
						  L&quot;KeyTestClass&quot;, 
						  L&quot;Key&quot;, 
						  WS_SYSMENU | WS_VISIBLE | WS_MINIMIZEBOX,
						  (GetSystemMetrics(SM_CXSCREEN)-WINDOW_WIDTH)/2, 
						  (GetSystemMetrics(SM_CYSCREEN)-WINDOW_HEIGHT)/2, 
						  WINDOW_WIDTH, 
						  WINDOW_HEIGHT, 
						  HWND_DESKTOP, 
						  NULL, 
						  hInstance, 
						  NULL
						 );

	while(GetMessage(&amp;msg, NULL, 0, 0))
	{
		TranslateMessage(&amp;msg); 
		DispatchMessage(&amp;msg);
	}
	return msg.wParam;
}

LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	PAINTSTRUCT ps;

	switch(message)
	{
		case WM_CREATE:
			hLibrary = LoadLibrary(L&quot;Key.dll&quot;);

			if (hLibrary == NULL)
				MessageBox(hwnd, L&quot;No DLL&quot;, L&quot;&quot;, NULL);

			Initialize = (ONINITIALIZE)GetProcAddress(hLibrary, &quot;OnInitialize&quot;);
			Shutdown = (ONSHUTDOWN)GetProcAddress(hLibrary, &quot;OnShutdown&quot;);

			if (Initialize == NULL)
				MessageBox(hwnd, L&quot;No Func OnInitialize&quot;, L&quot;&quot;, NULL);
			if (Shutdown == NULL)
				MessageBox(hwnd, L&quot;No Func OnShutdown&quot;, L&quot;&quot;, NULL);
			break;

		case (WM_USER+2):
			CurrentKey = wParam;
			InvalidateRect(hwnd, NULL, true);
			break;

		case WM_PAINT:
			hdc = BeginPaint(hwnd, &amp;ps);
				TextOut(hdc, 10, 10, &amp;CurrentKey, wcslen(&amp;CurrentKey));
			EndPaint(hwnd, &amp;ps);
			break;

		case WM_CLOSE:
			FreeLibrary(hLibrary); 
            DestroyWindow(hwnd);
			break;

		case WM_DESTROY:
			PostQuitMessage(0); 
			break;

		default: 
			return DefWindowProc(hwnd, message, wParam, lParam);
	}
	return 0;
}
</code></pre>
<p>Wo liegt hier das Problem? Ich hoffe hier kann mir jemand helfen. (Die DLL kann gefunden werden, nur die Funktionen nich).</p>
<p>€dit: Funktionen berichtigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/209639/dll-funktionen-nicht-gefunden</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 06:48:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/209639.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 01 Apr 2008 19:28:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Wed, 02 Apr 2008 11:18:27 GMT]]></title><description><![CDATA[<p>Hi, ich hab ne DLL geschrieben, die 2 Funktionen hat:</p>
<p>EXPORT BOOL CALLBACK OnInitialize(HWND);<br />
EXPORT BOOL CALLBACK OnShutdown(void);</p>
<p>Im Programm versuch ich darauf zuzugreifen, aber meine Messageboxen sagen immer wieder, dass die Funktionen nicht gefunden werden können. Warum? Ich habe mein altes Projekt nur überarbeitet (neue VS C++ Version) und schon gehts nich mehr oder was?</p>
<p>Header der DLL</p>
<pre><code class="language-cpp">#ifdef __cplusplus
#define EXPORT extern &quot;C&quot; __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif

EXPORT BOOL CALLBACK OnInitialize(HWND);
EXPORT BOOL CALLBACK OnShutdown(void);
</code></pre>
<p>Source der DLL</p>
<pre><code class="language-cpp">HINSTANCE   hDllInstance;

int APIENTRY DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
    switch (fdwReason)
	{
        case DLL_PROCESS_ATTACH :
            hDllInstance = hInstance ;
            break ;
    }  
    return TRUE ;
}

EXPORT BOOL CALLBACK OnInitialize(HWND hwnd)
{
//Funktionssource...
}

EXPORT BOOL CALLBACK OnShutdown()
{
//Funktionssource...
}
</code></pre>
<p>Hier der Source des Testprojekts für die DLL:</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;commctrl.h&gt;
#include &lt;commdlg.h&gt;

#define WINDOW_WIDTH	640
#define WINDOW_HEIGHT	480

#pragma warning(disable : 4996 )
#pragma comment(lib, &quot;comctl32.lib&quot;)

typedef bool(*ONINITIALIZE)(HWND hParent);
typedef bool (*ONSHUTDOWN)();

ONINITIALIZE Initialize = NULL;
ONSHUTDOWN Shutdown = NULL;

HMODULE hLibrary;

LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);

TCHAR CurrentKey;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
{
	HWND hwnd;
	MSG msg;
	WNDCLASSEX wcx;

	InitCommonControls();

	wcx.hInstance = hInstance;
	wcx.lpszClassName = L&quot;KeyTestClass&quot;;
	wcx.lpfnWndProc = WindowProcedure;
	wcx.style = CS_DBLCLKS;
	wcx.cbSize = sizeof(WNDCLASSEX);
	wcx.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
	wcx.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
	wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcx.lpszMenuName = NULL;
	wcx.cbClsExtra = 0;
	wcx.cbWndExtra = 0;
	wcx.hbrBackground = (HBRUSH) COLOR_BTNSHADOW;

	RegisterClassEx(&amp;wcx);

	//Hauptfenster
	hwnd = CreateWindowEx(0, 
						  L&quot;KeyTestClass&quot;, 
						  L&quot;Key&quot;, 
						  WS_SYSMENU | WS_VISIBLE | WS_MINIMIZEBOX,
						  (GetSystemMetrics(SM_CXSCREEN)-WINDOW_WIDTH)/2, 
						  (GetSystemMetrics(SM_CYSCREEN)-WINDOW_HEIGHT)/2, 
						  WINDOW_WIDTH, 
						  WINDOW_HEIGHT, 
						  HWND_DESKTOP, 
						  NULL, 
						  hInstance, 
						  NULL
						 );

	while(GetMessage(&amp;msg, NULL, 0, 0))
	{
		TranslateMessage(&amp;msg); 
		DispatchMessage(&amp;msg);
	}
	return msg.wParam;
}

LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	PAINTSTRUCT ps;

	switch(message)
	{
		case WM_CREATE:
			hLibrary = LoadLibrary(L&quot;Key.dll&quot;);

			if (hLibrary == NULL)
				MessageBox(hwnd, L&quot;No DLL&quot;, L&quot;&quot;, NULL);

			Initialize = (ONINITIALIZE)GetProcAddress(hLibrary, &quot;OnInitialize&quot;);
			Shutdown = (ONSHUTDOWN)GetProcAddress(hLibrary, &quot;OnShutdown&quot;);

			if (Initialize == NULL)
				MessageBox(hwnd, L&quot;No Func OnInitialize&quot;, L&quot;&quot;, NULL);
			if (Shutdown == NULL)
				MessageBox(hwnd, L&quot;No Func OnShutdown&quot;, L&quot;&quot;, NULL);
			break;

		case (WM_USER+2):
			CurrentKey = wParam;
			InvalidateRect(hwnd, NULL, true);
			break;

		case WM_PAINT:
			hdc = BeginPaint(hwnd, &amp;ps);
				TextOut(hdc, 10, 10, &amp;CurrentKey, wcslen(&amp;CurrentKey));
			EndPaint(hwnd, &amp;ps);
			break;

		case WM_CLOSE:
			FreeLibrary(hLibrary); 
            DestroyWindow(hwnd);
			break;

		case WM_DESTROY:
			PostQuitMessage(0); 
			break;

		default: 
			return DefWindowProc(hwnd, message, wParam, lParam);
	}
	return 0;
}
</code></pre>
<p>Wo liegt hier das Problem? Ich hoffe hier kann mir jemand helfen. (Die DLL kann gefunden werden, nur die Funktionen nich).</p>
<p>€dit: Funktionen berichtigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484782</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484782</guid><dc:creator><![CDATA[Nolf]]></dc:creator><pubDate>Wed, 02 Apr 2008 11:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Tue, 01 Apr 2008 19:44:01 GMT]]></title><description><![CDATA[<p>Schau mal mit<br />
<a href="http://www.dependecywalker.com" rel="nofollow">www.dependecywalker.com</a><br />
nach wie die Funktionen in der DLL *wirklich* heissen!</p>
<p>Verwende dann eine DEF-Datei, damit sie den Namen bekommen, wie Du willst...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484799</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484799</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Tue, 01 Apr 2008 19:44:01 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Tue, 01 Apr 2008 22:10:23 GMT]]></title><description><![CDATA[<p>Naja wirklich heißen tun sie:</p>
<p>_OnInitialize und _OnShutdown</p>
<p>und die laufen auch nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484875</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484875</guid><dc:creator><![CDATA[Nolf]]></dc:creator><pubDate>Tue, 01 Apr 2008 22:10:23 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Tue, 01 Apr 2008 22:35:15 GMT]]></title><description><![CDATA[<p>Die erste MessageBox wird angezeigt wenn &quot;HookSetup&quot; == NULL ist. Prüf lieber mal ob &quot;Initialize&quot; == NULL ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484885</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 01 Apr 2008 22:35:15 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Tue, 01 Apr 2008 22:46:14 GMT]]></title><description><![CDATA[<p>roflé...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484889</guid><dc:creator><![CDATA[rofler]]></dc:creator><pubDate>Tue, 01 Apr 2008 22:46:14 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Wed, 02 Apr 2008 07:59:19 GMT]]></title><description><![CDATA[<p>Nolf schrieb:</p>
<blockquote>
<p>Naja wirklich heißen tun sie:<br />
_OnInitialize und _OnShutdown<br />
und die laufen auch nicht.</p>
</blockquote>
<p>naja, ich würde eher sagen die heissen:<br />
_OnInitialize@4 und _OnShutdown@0</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1484984</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1484984</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 02 Apr 2008 07:59:19 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Wed, 02 Apr 2008 11:02:48 GMT]]></title><description><![CDATA[<p>Joa ich weis aber das hab ich ja nich mitgeschrieben ich kann das ja nicht so in den Quellcode übernehmen oder?<br />
Zu dem Hooksetup: Das ist einfach nur ein schreibfehler weils die Variable nicht gibt, ich hab den Quellcode im Forum hier ein bissn umgeändert also daran liegts nicht.</p>
<p>Edit: Es funktioniert. Ich hab die doch mit dem <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/3607">@x</a> geschrieben aber warum ist das so? Ich hab die Funktionen doch nicht so benannt oder sind das Positionsangaben im Code?</p>
<p>Ein Problem kommt aber noch: Wenn ich die OnShutdown funktion EGAL wo verwende, stürzt mein Programm einfach ab.<br />
Der Debugger sagt:</p>
<p>Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.</p>
<p>Das verstehe ich nicht wirklich. Was bedeutet das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485085</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485085</guid><dc:creator><![CDATA[Nolf]]></dc:creator><pubDate>Wed, 02 Apr 2008 11:02:48 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Wed, 02 Apr 2008 11:07:34 GMT]]></title><description><![CDATA[<p>Nolf schrieb:</p>
<blockquote>
<p>Joa ich weis aber das hab ich ja nich mitgeschrieben ich kann das ja nicht so in den Quellcode übernehmen oder?</p>
</blockquote>
<p>Du sollst ja auch eine DEF-Datei verwenden, damit die Namen so sind wie Du sie erwartest... (sag ich schon zum 2. Mal).</p>
<p>Nolf schrieb:</p>
<blockquote>
<p>Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.</p>
</blockquote>
<p>In der DLL wird die Funktion als __stdcall definiert und Du verwendest sie als __cdecl.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485111</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485111</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Wed, 02 Apr 2008 11:07:34 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Wed, 02 Apr 2008 11:30:11 GMT]]></title><description><![CDATA[<p>OK ich habs mit den Funktionen verändert (in den Projekteinstellungen auf __stdcall gesetzt [geht das auch im Quellcode?]). Sorry ich kenn mich mit den DEF dateien nicht aus und deswegen habe ich darauf nicht geachtet. Diese <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/3607">@x</a> stören auch nicht so.</p>
<p>Danke<br />
mfg Nolf</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485128</guid><dc:creator><![CDATA[Nolf]]></dc:creator><pubDate>Wed, 02 Apr 2008 11:30:11 GMT</pubDate></item><item><title><![CDATA[Reply to DLL-Funktionen nicht gefunden on Wed, 02 Apr 2008 22:10:49 GMT]]></title><description><![CDATA[<p>stells nicht in den projekteinstellungen um, nur die funktionen, die du aus der dll importierst musste __stdcall benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1485556</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1485556</guid><dc:creator><![CDATA[rofler]]></dc:creator><pubDate>Wed, 02 Apr 2008 22:10:49 GMT</pubDate></item></channel></rss>