MFC & DLL

How do I export data from an MFC application to a DLL???
sischujaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shay050799Commented:
as far as i know, u need a callback function inside ur DLL
0
inprasCommented:
What U mean export data?
0
hrumayorCommented:
There are three types of dll that MFC implemented well realy it is only one but they added code to make your life easy (rigth), we have the regular and extension DLL's, and the normal dll with no MFC.

regular dll's have the ability to load resources very easy with the command macro AFX_MANAGE_STATE(AfxGetStaticModuleState())
you load the resources of the dll so you can use this command inside a function call to a dialog and show the correct dialog form the resources.

The extension dll's are a try of microsoft in making a dll like if it was of the apication the resources of the dll are merged with the ones on the aplication so if you have repeated resoureces id in the DLL and exe you will have trouble but the advantage it that they are very easy to use you only add the macro AFX_EXT_CLASS on the begining of our clases and they are exported over the boundaries of the DLL so you can iclude the header of your dll's classes on the exe and you can start using it. Well before add the library so it can be linked with the dll.

You can also get the addres of a function in a dll with GetProcAddres previosly loading it with LoadLibrary you must export funcions on the dll in the def file or use the microsoft specific commands __declspec(dllexport)

Well to answer the question you have to get an addres of a function in the dll and with this funcion you can implement code that returns you the addres of a structure you can use this pointer ans write data to it. because they are on the same addres space. be aware of problems like making a new on the dll and making the delete in the exe this is not safe do a the delete and new on the same side it was made this has to do with the way the new and delete comands are impemented.

You can also consider the use of COM or a ligth version of com that you could implement.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.