Solved

Converting from EXE to DLL

Posted on 1998-07-06
4
260 Views
Last Modified: 2013-11-20
I have two executables which I would like to convert to DLLs. Currently the first executable creates a window for
text input and the second creates a window for drawing input. I would like to write another application that will
display either the writing or the drawing window in response to a switch. Therefore the new application will have to create and display the writing and drawing windows, using CreateWindow (I think).

I know that I can create a new project as a DLL and import my classes. Do I have to create a MFC DLL or can I just create a Win32 DLL project and copy the code directly? How do I get my classes to be registered so I can use CreateWindow?

I will increase the number of points if it is necessary.

0
Comment
Question by:horn
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
motigust earned 170 total points
Comment Utility
I'm assuming that you are using MFC.
It seems that the best solution for you is the create 2 MFC Dlls and copy the code into it. The reason is that your code should be linked with the MFC DLLs or Static Libraries beacause it is using it.

So that's what you should do:

1. Create 2 MFC DLLs.

2. Add your code into the DLL Project

3. All the code should remain the same, except from functions that are using resources, these functions should have the following line as the first one:
AFX_MANAGE_STATE(AfxGetStaticModuleState());

4. All the functions that are exported, should look somthing like this when compiled in the DLL:
int __declspec(dllexport) MyFunc();

all the functions that are imported, should look somthing like this when compiled in the code that is using the DLL:
int __declspec(dllimport) MyFunc();


Good luck,

Have fun,

Moti :-)
0
 

Author Comment

by:horn
Comment Utility
What should I do about importing resources?
0
 
LVL 1

Expert Comment

by:motigust
Comment Utility
I'm not sure I understood what you ment..
When you are creating a MFC DLL using the wizard, it is created with a resource file, you may put all your resources there. So, you may use your resources the same way that you are using them now.

But again, remember to put the
AFX_MANAGE_STATE(AfxGetStaticModuleState());
at the begining of each function that uses the resources.

0
 

Author Comment

by:horn
Comment Utility
OK, I understand what you mean about the resources -- that in itself answered my question! Thanks.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

763 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

12 Experts available now in Live!

Get 1:1 Help Now