converting .exe to .dll

hello there
I have question. I have a running .exe program. i want to convert this .exe into a .dll file which I can use in a different application.
can any one walk me through this particular problem. Its really urgent for me to get this done asap. so plz reply at the earliest
Thanks in advance. Bye
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.

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
You could do it by removing 'main' from your app and changing a lot of project settings so it will compile properly.  It's not really that hard but it's easy to miss something.

An easier solution is to create an empty dll project, move the source files from the executable into the dll project directory (or move the dll project files into the directory where the executable source code is if you don't need the executable project any more) and then add all the source files to the dll project.  You will still need to remove the 'main' function in either case.

To use functionality from the dll, however, you will need to export classes, functions, and data you want to use in other projects.  To make sure things are exported and later imported correctly, you should define a preprocessor macro and use it to define dllexport or dllimport like this:

#ifdef IN_MY_DLL
   #define MY_DLL_IMPORT __declspec(dllexport)
   #define MY_DLL_IMPORT __declspec(dllimport)

then use 'MY_DLL_IMPORT' on things you want to be exported from your dll.  Make sure these are included in headers that will be used by importing projects later.  Your dll should define 'IN_MY_DLL' (name it as you like and change the sample) in the dll project but NOT in importingprojects.  This will correctly export/import things.

Read the docs on dllexport/dllimport to see where to put 'MY_DLL_IMPORT' (use in place of __declspec(dll??port)):

Once done, you can recreate the original executable by leaving the 'main' function in the original project and linking with the new dll you created.  This would require moving the rest of the source into the new dll project directory.
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
Visual C++.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.