Solved

Converting from EXE to DLL

Posted on 1998-07-06
4
261 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
ID: 1318783
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
ID: 1318784
What should I do about importing resources?
0
 
LVL 1

Expert Comment

by:motigust
ID: 1318785
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
ID: 1318786
OK, I understand what you mean about the resources -- that in itself answered my question! Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 55
Hibernate methods 2 68
Smart Camera scanning and reading information 3 99
bigDiff challenge 17 83
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. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

20 Experts available now in Live!

Get 1:1 Help Now