Solved

Converting from EXE to DLL

Posted on 1998-07-06
4
264 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 3 194
java ^ examples 8 73
modThree challenge 4 153
Problem to App 4 143
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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

737 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