views:

374

answers:

3

is it possible to develop DLL for both win32 console and MFC GUI. If yes please explain.

What i want to do is to create dll that contains certain API's for both win32 console and MFC GUI.

A: 

There is no reason we cannot do this. You can do it either the traditional dllexport, dllimport way or you can just create a COM dll.

Atempcode
+3  A: 

Yes - native dlls are structured in exactly the same way when used with console and MFC applications.

The easiest way to do what you want is to create a new plain Win32 project in visual studio, and in application settings set the Application Type to DLL. Select the export symbols checkbox, and the project will include:

#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif

You can can then define any functions you want to export from the DLL with TEST_API (or whatever it is called in your application), e.g.

TEST_API int fnTest(void);

and they will be callable from both an MFC and console application.

John Sibly
Thanks for Elegant Answer :).
mahesh
+1  A: 

Your question has no sense at all. Read MSDN detailed doc on DLLs as you don't know what it is