Hi nielsboldt,
if I understand you right you want to make a DLL which is implicitely linked, so you don't want to load/call the DLL at runtime using LoadLibrary/GetProcAddress
To do so first step is to create a new Win32 project of type DLL - depending on your needs you can use MFC and/or ATL there. You need to take care that you use the same C-Runtime libraries (static or dynamically linked, single ot multithreaded) as in the calling application.
Next you need to export the functions/classes you want to use in the calling application. Therefor you can declare a macro in your header files somehow like this:
#ifdef MY_APP_EXPORT
#define MY_APP_API __declspec(dllexport)
#else
#define MY_APP_API __declspec(dllimport)
#endif
The MY_APP_EXPORT should be declared in the comile-settings 'Preprocessor->Preprocesso
Then you can declare any function or class you want to export in header files like this:
void MY_APP_API foo();
class MY_APP_API MyClass
{
...
};
This way you can use the same header both in the DLL and the calling application - in the DLL the macro expands to __declspec(dllexport) which exports the declared functions/classes, in the calling application the macro expands to __declspec(dllimport) which declares the functions/classes in a way the compiler will generate import code.
Then you only have to link the .LIB which is built with the DLL to the application in order to use the exported functions/classes in the application.
I hope that helps,
ZOPPO
Main Topics
Browse All Topics





by: jkrPosted on 2007-08-02 at 06:26:04ID: 19616624
See the articles under http://www.codeproject.com /dll/#Begi nners - especially http://www.codeproject.com /dll/EasyD LL.asp ("Super Easy DLL") and http://www.codeproject.com /dll/DLL_E Z_Build_EZ _Usage.asp ("Making DLLs easy to build and use") which are both compact and will give you a jump start on this issue.