<?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 DLL-Erstellung unter VC++, help!]]></title><description><![CDATA[<p>Hallö'chen,<br />
Ich wollte mich mal weiter mit dem &quot;Microsoft Visual Studion C++ 6.0&quot; beschäftigen und dachte du probierst es noch mal mit nem Global KbHoob <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="😃"
    /><br />
Naja aber irgendwie hat der Compiler was dagegen. Ich habe das Codebeispiel von 'toom' aus der FAQ <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39383.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39383.html</a><br />
verwendet. Habe also folgende Schritte im VC++ gemacht:<br />
-&gt; Neues Project<br />
-&gt; Menüpunkt &quot;Win32 Dynamic-Link Library&quot; ( wens interessiert Name: &quot;KbHook&quot; )<br />
-&gt; Weiter<br />
-&gt; &quot;Ein einfaches DLL Projekt&quot;<br />
-&gt; Weiter<br />
-&gt; dann habe ich erstmal die:</p>
<pre><code class="language-cpp">BOOL APIENTRY DllMain( HANDLE hModule,  DWORD ul_reason_for_call, LPVOID lpReserved ) {

    return TRUE;
}
</code></pre>
<p>durch das ersetzt (obweohl das eigentlich nur ne kleine Schönheitskorektur war)</p>
<pre><code class="language-cpp">int WINAPI DllMain( HINSTANCE hInstance, DWORD fdReason, PVOID pvReserved ) {

   return true;
}
</code></pre>
<p>-&gt; Dann habe ich dem Projekt noch einen Header zugefügt mit gleichen Namen der .cpp-Datei und die Prototypen reingesteckt</p>
<pre><code class="language-cpp">#ifdef __cplusplus
#define EXPORT extern &quot;C&quot; __declspec( dllexport )
#else
#define EXPROT __declspec( dllexport )
#endif

EXPORT BOOL CALLBACK InstallKbHook( HWND );
EXPORT BOOL CALLBACK UnistallKbHook( );
</code></pre>
<p>-&gt; Und den rest habe ich so wie im FAQ-Thread auch übernommen:</p>
<pre><code class="language-cpp">//--- Includes -----------------------------------------------------

#include &quot;stdafx.h&quot;

//--- Gloabals -----------------------------------------------------

#pragma data_seg( &quot;shared&quot; )
HWND hWnd = 0;
#pragma data_seg( )
#pragma comment( linker, &quot;/section:shared,RWS&quot; )

HHOOK hHook;
HINSTANCE hInstDLL;

//--- Prototypes ---------------------------------------------------

LRESULT CALLBACK KeyboardProc( int, WPARAM, LPARAM );

//--- DllMain ------------------------------------------------------

int WINAPI DllMain( HINSTANCE hInstance, DWORD fdReason, PVOID pvReserved ) {

	switch( fdReason ) {

		case DLL_PROCESS_ATTACH: {

			hInstDLL = hInstance;
			break;
		}

		case DLL_THREAD_ATTACH: {

			break;
		}

		case DLL_PROCESS_DETACH: {

			break;
		}

		case DLL_THREAD_DETACH: {

			break;
		}
    return TRUE;
}

//--- Definitons ---------------------------------------------------

// ***** This func set the global hook *****
EXPORT BOOL CALLBACK InstallKbHook( HWND hWindow ) {

	hWnd = hWindow;

	hHook = SetWindowsHookEx( WH_KEYBOARD, KeyboardProc, hInstDLL, 0 );
	return true;
}

// ***** This func remove the global hook *****
EXPORT BOOL CALLBACK UnistallKbHook( ) {

	UnhookWindowsHookEx( hHook );
	return true;
}

// ***** This func is the message rotine *****
LRESULT CALLBACK KeyboardProc( int nCode, WPARAM wParam, LPARAM lParam ) {

	if( nCode == HC_ACTION ) {

		SendMessage( hWnd, ( WM_USER + 2 ), wParam, lParam );
	}
	return( CallNextHookEx( hHook, nCode, wParam, lParam ) );
}

//--- EXIT ---------------------------------------------------------
</code></pre>
<p>-&gt; achja ich hab den eingefügten header in die stdafx.h gepackt, dürfte aber nicht relevant sein.</p>
<p>Tjo und dann wollte ich das ganz mal Compilieren und das hatte ich nun davon:</p>
<pre><code>--------------------Configuration: KbHook - Win32 Debug--------------------
Compiling...
KbHook.cpp
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(64) : error C2598: linkage specification must be at global scope
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(64) : error C2601: 'InstallKbHook' : local function definitions are illegal
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(73) : error C2598: linkage specification must be at global scope
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(73) : error C2601: 'UnistallKbHook' : local function definitions are illegal
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(80) : error C2601: 'KeyboardProc' : local function definitions are illegal
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(91) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

KbHook.dll - 6 error(s), 0 warning(s)
</code></pre>
<p>Ich weiß echt nicht wieso aber ich hoffe ihr könnts mir sagen und mir halfen.</p>
<p>Gruß Tobi.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196830/problem-mit-dll-erstellung-unter-vc-help</link><generator>RSS for Node</generator><lastBuildDate>Sat, 02 May 2026 02:56:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196830.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Nov 2007 13:26:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit DLL-Erstellung unter VC++, help! on Sat, 03 Nov 2007 13:26:46 GMT]]></title><description><![CDATA[<p>Hallö'chen,<br />
Ich wollte mich mal weiter mit dem &quot;Microsoft Visual Studion C++ 6.0&quot; beschäftigen und dachte du probierst es noch mal mit nem Global KbHoob <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="😃"
    /><br />
Naja aber irgendwie hat der Compiler was dagegen. Ich habe das Codebeispiel von 'toom' aus der FAQ <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39383.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-39383.html</a><br />
verwendet. Habe also folgende Schritte im VC++ gemacht:<br />
-&gt; Neues Project<br />
-&gt; Menüpunkt &quot;Win32 Dynamic-Link Library&quot; ( wens interessiert Name: &quot;KbHook&quot; )<br />
-&gt; Weiter<br />
-&gt; &quot;Ein einfaches DLL Projekt&quot;<br />
-&gt; Weiter<br />
-&gt; dann habe ich erstmal die:</p>
<pre><code class="language-cpp">BOOL APIENTRY DllMain( HANDLE hModule,  DWORD ul_reason_for_call, LPVOID lpReserved ) {

    return TRUE;
}
</code></pre>
<p>durch das ersetzt (obweohl das eigentlich nur ne kleine Schönheitskorektur war)</p>
<pre><code class="language-cpp">int WINAPI DllMain( HINSTANCE hInstance, DWORD fdReason, PVOID pvReserved ) {

   return true;
}
</code></pre>
<p>-&gt; Dann habe ich dem Projekt noch einen Header zugefügt mit gleichen Namen der .cpp-Datei und die Prototypen reingesteckt</p>
<pre><code class="language-cpp">#ifdef __cplusplus
#define EXPORT extern &quot;C&quot; __declspec( dllexport )
#else
#define EXPROT __declspec( dllexport )
#endif

EXPORT BOOL CALLBACK InstallKbHook( HWND );
EXPORT BOOL CALLBACK UnistallKbHook( );
</code></pre>
<p>-&gt; Und den rest habe ich so wie im FAQ-Thread auch übernommen:</p>
<pre><code class="language-cpp">//--- Includes -----------------------------------------------------

#include &quot;stdafx.h&quot;

//--- Gloabals -----------------------------------------------------

#pragma data_seg( &quot;shared&quot; )
HWND hWnd = 0;
#pragma data_seg( )
#pragma comment( linker, &quot;/section:shared,RWS&quot; )

HHOOK hHook;
HINSTANCE hInstDLL;

//--- Prototypes ---------------------------------------------------

LRESULT CALLBACK KeyboardProc( int, WPARAM, LPARAM );

//--- DllMain ------------------------------------------------------

int WINAPI DllMain( HINSTANCE hInstance, DWORD fdReason, PVOID pvReserved ) {

	switch( fdReason ) {

		case DLL_PROCESS_ATTACH: {

			hInstDLL = hInstance;
			break;
		}

		case DLL_THREAD_ATTACH: {

			break;
		}

		case DLL_PROCESS_DETACH: {

			break;
		}

		case DLL_THREAD_DETACH: {

			break;
		}
    return TRUE;
}

//--- Definitons ---------------------------------------------------

// ***** This func set the global hook *****
EXPORT BOOL CALLBACK InstallKbHook( HWND hWindow ) {

	hWnd = hWindow;

	hHook = SetWindowsHookEx( WH_KEYBOARD, KeyboardProc, hInstDLL, 0 );
	return true;
}

// ***** This func remove the global hook *****
EXPORT BOOL CALLBACK UnistallKbHook( ) {

	UnhookWindowsHookEx( hHook );
	return true;
}

// ***** This func is the message rotine *****
LRESULT CALLBACK KeyboardProc( int nCode, WPARAM wParam, LPARAM lParam ) {

	if( nCode == HC_ACTION ) {

		SendMessage( hWnd, ( WM_USER + 2 ), wParam, lParam );
	}
	return( CallNextHookEx( hHook, nCode, wParam, lParam ) );
}

//--- EXIT ---------------------------------------------------------
</code></pre>
<p>-&gt; achja ich hab den eingefügten header in die stdafx.h gepackt, dürfte aber nicht relevant sein.</p>
<p>Tjo und dann wollte ich das ganz mal Compilieren und das hatte ich nun davon:</p>
<pre><code>--------------------Configuration: KbHook - Win32 Debug--------------------
Compiling...
KbHook.cpp
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(64) : error C2598: linkage specification must be at global scope
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(64) : error C2601: 'InstallKbHook' : local function definitions are illegal
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(73) : error C2598: linkage specification must be at global scope
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(73) : error C2601: 'UnistallKbHook' : local function definitions are illegal
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(80) : error C2601: 'KeyboardProc' : local function definitions are illegal
C:\Programme\Microsoft Visual Studio\MyProjects\Global KbHook\KbHook\KbHook.cpp(91) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

KbHook.dll - 6 error(s), 0 warning(s)
</code></pre>
<p>Ich weiß echt nicht wieso aber ich hoffe ihr könnts mir sagen und mir halfen.</p>
<p>Gruß Tobi.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1396987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1396987</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Sat, 03 Nov 2007 13:26:46 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit DLL-Erstellung unter VC++, help! on Sat, 03 Nov 2007 18:13:04 GMT]]></title><description><![CDATA[<p>keiner ne idee?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397135</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Sat, 03 Nov 2007 18:13:04 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit DLL-Erstellung unter VC++, help! on Sun, 04 Nov 2007 09:24:25 GMT]]></title><description><![CDATA[<p>wirklich niemand? oO</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397336</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397336</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Sun, 04 Nov 2007 09:24:25 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit DLL-Erstellung unter VC++, help! on Sun, 04 Nov 2007 13:00:49 GMT]]></title><description><![CDATA[<p><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="😃"
    /> oO... ich habs jetzt<br />
wooah wie ich diese kleinen Fehler immer hasse eh ich die gefunden hab is immer Winachten... einmal ne Klammer vergessen und und einmal stat EXPOR, EXPROT getippt wo bei das den fahler nicht verursacht haett ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397447</guid><dc:creator><![CDATA[T0bi]]></dc:creator><pubDate>Sun, 04 Nov 2007 13:00:49 GMT</pubDate></item></channel></rss>