Click here to Skip to main content
15,894,362 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to use winsock2 Pin
Simon.W7-Jan-03 19:41
Simon.W7-Jan-03 19:41 
Questionprojects that I can contribute towards? Pin
tiglic_acid7-Jan-03 17:53
tiglic_acid7-Jan-03 17:53 
AnswerRe: projects that I can contribute towards? Pin
Jim Crafton7-Jan-03 18:05
Jim Crafton7-Jan-03 18:05 
QuestionMenu ??? Pin
dktu7-Jan-03 17:39
dktu7-Jan-03 17:39 
AnswerRe: Menu ??? Pin
l a u r e n7-Jan-03 17:57
l a u r e n7-Jan-03 17:57 
AnswerRe: Menu ??? Pin
Simon.W7-Jan-03 19:49
Simon.W7-Jan-03 19:49 
GeneralNeed help with dlls Pin
VanHlebar7-Jan-03 16:41
VanHlebar7-Jan-03 16:41 
GeneralRe: Need help with dlls Pin
Jim Crafton7-Jan-03 17:58
Jim Crafton7-Jan-03 17:58 
make you public header for your function(s)

foo.h
#ifndef _FOO_H__
#define _FOO_H__



#ifdef USE_MY_LIBRARY
    #define MY_LIB_API   __declspec(dllimport) 
#else
    #define MY_LIB_API   __declspec(dllexport) 
#endif


#extern "C" {
    MY_LIB_API void MyFunc( int aValue );
}

#endif



implement the function in some file that is compiled for your DLL
say
Foo.c

#include "Foo.h"

void MyFunc( int aValue )
{
//do something
}

when you compile the DLL make sure that USE_MY_LIBRARY is NOT defined. this will ensure that you are using the __declspec(dllexport) form of the function and will automatically export the function for you.


You should end up with a DLL that exports a single function (assuming these are the only files). The extern "C" guarantees that you will not have name mangling.

You can use the DLL with either LoadLibrary() and GetProcAddress(), which is the hard way, or you can make sure that your DLL project emits a .lib file and in the project that uses the DLL, link with this .lib file. If you choose the latter method, make sure that USE_MY_LIBRARY is defined.

Cheers and hope this helps

¡El diablo está en mis pantalones! ¡Mire, mire!
GeneralRe: Need help with dlls Pin
TOMTEFAR7-Jan-03 20:41
TOMTEFAR7-Jan-03 20:41 
GeneralListBox WM_VKEYTOITEM misbehaves! Pin
Brian Tietz7-Jan-03 15:30
Brian Tietz7-Jan-03 15:30 
GeneralRe: ListBox WM_VKEYTOITEM misbehaves! Pin
Brian Tietz7-Jan-03 16:01
Brian Tietz7-Jan-03 16:01 
GeneralRe: ListBox WM_VKEYTOITEM misbehaves! Pin
l a u r e n7-Jan-03 18:00
l a u r e n7-Jan-03 18:00 
GeneralCDataGrid Pin
Gilfrog7-Jan-03 12:11
Gilfrog7-Jan-03 12:11 
GeneralWM_TIMER and SetTimer Pin
Sunnygirl7-Jan-03 12:02
Sunnygirl7-Jan-03 12:02 
GeneralRe: WM_TIMER and SetTimer Pin
Mike Nordell7-Jan-03 15:49
Mike Nordell7-Jan-03 15:49 
GeneralArrays of control Pin
TV7-Jan-03 10:21
TV7-Jan-03 10:21 
GeneralRe: Arrays of control Pin
Alvaro Mendez7-Jan-03 11:50
Alvaro Mendez7-Jan-03 11:50 
GeneralRe: Arrays of control Pin
Heywood7-Jan-03 12:50
Heywood7-Jan-03 12:50 
GeneralRe: Arrays of control Pin
Andreas Saurwein8-Jan-03 0:38
Andreas Saurwein8-Jan-03 0:38 
Generalsystem, _wsystem calls within MSVC++ dialog applications Pin
rghin7-Jan-03 8:49
rghin7-Jan-03 8:49 
GeneralRe: system, _wsystem calls within MSVC++ dialog applications Pin
AlexO7-Jan-03 9:15
AlexO7-Jan-03 9:15 
GeneralRe: system, _wsystem calls within MSVC++ dialog applications Pin
valikac7-Jan-03 9:25
valikac7-Jan-03 9:25 
GeneralRe: system, _wsystem calls within MSVC++ dialog applications Pin
Alvaro Mendez7-Jan-03 9:25
Alvaro Mendez7-Jan-03 9:25 
GeneralWindows Hooks Pin
Nnamdi Onyeyiri7-Jan-03 8:07
Nnamdi Onyeyiri7-Jan-03 8:07 
GeneralRe: Windows Hooks Pin
Nish Nishant7-Jan-03 10:05
sitebuilderNish Nishant7-Jan-03 10:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.