Solved

Converting from EXE to DLL

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

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
Different colored text in ComboBox without Subclassing 8 66
Separate into files by filename 12 87
Capture logon name 13 88
Authenticate using sesu from script 7 60
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 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