Hi all,

For later use I want to create dll file, internally using MFC. I used MFC because it is so easy to do my job. So used the MFC-DLL Visual C++ project and code my project. Its ok.

Later add another Console Application which support MFC as well. I want to use it to send data to the dll externally. Simply pass a std::string to dll, and there use that string for processing.

My question is how can I connect those two projects together. How to send data to dll application from the console application.

DLLs are much like normal static libraries. Create a header file with the dll functions you have exported and include it in your console project, then add the .lib file that the compiler created for the dll in the console project just like you would any other project.

I use a conditional compile preprocessor directives in the header file so that it can be included in both the dll build and the console application build

// header file
#if defined(DLL_BUILD)
#define MYAPI __dllexport
#else
#define MYAPI __dllimport
#endif

void MYAPI foo(std::string& datastr);

DLLs are much like normal static libraries. Create a header file with the dll functions you have exported and include it in your console project, then add the .lib file that the compiler created for the dll in the console project just like you would any other project.

I use a conditional compile preprocessor directives in the header file so that it can be included in both the dll build and the console application build

// header file
#if defined(DLL_BUILD)
#define MYAPI __dllexport
#else
#define MYAPI __dllimport
#endif

void MYAPI foo(std::string& datastr);

Thanks,

I've read few articles and get really mess with this header file and stuff. I think it is better to find a complete document on dll and read it first. I collect a document and going to read it tonight. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.