converting .exe to .dll

Posted on 2004-10-28
Last Modified: 2010-04-24
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
Question by:vikrantp
    LVL 6

    Accepted Solution

    LVL 19

    Assisted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now