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
vikrantpAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
drichardsConnect With a Mentor Commented:
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)
#else
   #define MY_DLL_IMPORT __declspec(dllimport)
#endif

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)):
   http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_the_dllexport_and_dllimport_attributes.asp

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.
0
All Courses

From novice to tech pro — start learning today.