?
Solved

Converting from EXE to DLL

Posted on 1998-07-06
4
Medium Priority
?
266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
motigust earned 680 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

771 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