Help: How to convert an EXE to a DLL
Prakash N -- pran@wings.xko.dec.com
Wednesday, July 31, 1996
Environment: VC++ 4.0, Win 95
Hello!
I am half-way through in developing a MFC application. For the time =
being, the application is an MDI application and it has its own =
resources. Now, I feel it will be better if this application is made as =
a DLL. Is there any direct way of "converting" the existing EXE into a =
DLL? Or do I have to start the DLL from the scratch by putting all the =
functionalities of the EXE into it? (Which I hate to do... of course! )
The Microsoft documentation (Programming with MFC) doesn't talk about =
this conversions. Also, David Kruglinski doesn't discuss this particular =
topic.
In Borland C++, at any time during development, we can change the =
settings and convert an EXE into DLL. Since MSVC *generates* the files, =
will it be possible for it to convert the application into a DLL?=20
Anybody who has some experience on this... please throw some light...
Cheers,
Prakash N
DEC, India.
pran@wings.xko.dec.com
Mike Blaszczak -- mikeblas@nwlink.com
Sunday, August 04, 1996
At 05:14 PM 7/31/96 +-5-30, you wrote:
>Environment: VC++ 4.0, Win 95
Hi.
>I am half-way through in developing a MFC application. For the time
>being, the application is an MDI application and it has its own resources.
>Now, I feel it will be better if this application is made as a DLL.
You can't make an application into a DLL, just like you can't make a
car into a hardware store.
[Moderator's note: I beg to differ, at least in some special
cases. I turned a dialog-based application into a control panel
DLL in just a few minutes. It's a far cry from an MDI application,
but it still fits into your generalization.]
A DLL is a disparate collection of functions that don't mean anything.
An application is a complete program that starts, runs, and finishes in
a very determined order of execution.
>Is there any direct way of "converting" the existing EXE into a DLL?
By "direct", do you mean "automatic"? No, there isn't: it just doesn't
make any sense to do so. What would happen to WinMain() when you started
using a DLL? What if some function that you wanted to export from
the DLL actually needs to rely on data initialized by the WinMain()'s
processing of the command line? Since DLLs don't have a command line,
what is going to happen?
>Or do I have to start the DLL from the scratch by putting all the
>functionalities of the EXE into it?
Yes.
> (Which I hate to do... of course! )
Sometimes, you have to actually _earn_ your paycheque.
>In Borland C++, at any time during development, we can change the
>settings and convert an EXE into DLL.
That surprises me deeply. Where does Borland C++ decide to get the DllMain()
in a project that doesn't have a DllMain()? What happens to the code you
used to have in WinMain()?
.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.
Bradley A. Burns -- bburns@sprynet.com
Thursday, August 08, 1996
[Mini-digest: 3 responses]
Hi there, Prakash...
There are a couple of topics to focus on here... first, I've used BC++ for
too long, and yes, you can change the project settings to DLL when the
project had already been started. With the new project settings, the code
might actually compile, but just try getting the newly created so-called
pseudo-BC-DLL to actually get instantiated.
As far as converting your existing MDI application into a DLL, Mike B. is
correct in saying that this effort would have to be earned, depending on
how far you are into the project and also its size. It also depends on WHY
you want to do this... will the code/resources in this new DLL be used by
anything else you are working on or will be working on in the future???
Will you be needing system-wide hooks? If the answer is no to all of these
questions, I would ask myself whether or not it's even worth spending the
time concentrating on making this into a DLL.
Bradley A. Burns
bburns@sprynet.com
----------
From: Prakash N
To: 'MFC'
Subject: Help: How to convert an EXE to a DLL
Date: Wednesday, July 31, 1996 12:14 PM
Environment: VC++ 4.0, Win 95
Hello!
I am half-way through in developing a MFC application. For the time being,
the application is an MDI application and it has its own resources. Now,
I feel it will be better if this application is made as a DLL. Is there
any direct way of "converting" the existing EXE into a DLL? Or do I have
to start the DLL from the scratch by putting all the functionalities of
the EXE into it? (Which I hate to do... of course! )
The Microsoft documentation (Programming with MFC) doesn't talk about this
conversions. Also, David Kruglinski doesn't discuss this particular
topic.
In Borland C++, at any time during development, we can change the settings
and convert an EXE into DLL. Since MSVC *generates* the files, will it be
possible for it to convert the application into a DLL?
Anybody who has some experience on this... please throw some light...
Cheers,
Prakash N
DEC, India.
pran@wings.xko.dec.com----------
-----From: Mike Blaszczak
At 10:48 PM 8/4/96 -0700, Mike Blaszczak wrote:
>You can't make an application into a DLL, just like you can't make a
>car into a hardware store.
>
>[Moderator's note: I beg to differ, at least in some special
>cases. I turned a dialog-based application into a control panel
>DLL in just a few minutes. It's a far cry from an MDI application,
>but it still fits into your generalization.]
Maybe my generalization is flawed, but "How do I convert an application
into a Control Panel DLL" is a very different question.
I said:
>A DLL is a disparate collection of functions that don't mean anything.
>An application is a complete program that starts, runs, and finishes in
>a very determined order of execution.
If you say that you're writing a CPL module, you've got lots of rules which
you can rely on. You know that the CPL will be loaded and have a certain
entry point (CPLApplet, right?) called so it can initialize and run. When
the user is done with your control panel extension, it shuts down in an
orderly manner.
Windows defines several special DLL styles like this: CPL's, MAPI extensions,
ISAPI extensions, File Manager extensions, Shell Extensions, "old-style"
API-based common controls, and so on.
These things, while packaged in the vehicle of a DLL, are a _far_ cry from
a generic DLL. A generic DLL is simply a collection of functions which
might be called (or not be called) in any order. Since an EXE has a
well-defined lifecycle, I don't think it's possible to translate, without
context, from a generic EXE to a generic DLL and expect to get something
meaningful.
Saying that the DLL isn't generic and is targeted at some special application
gives enough information: you know that you can probably fold everything
from your WinMain() into a CPL extension, for example, by hanging everything
from the CPLApplet entrypoint. But, even then, the translation isn't
a blind "conversion" as the person who asked the question wanted--CPLApplet
doesn't get a command line, while WinMain() does. You can't expect software
to "convert" from a generic EXE (which might do anything, including party
on the command line) to a control panel extension (which can only do a
limited set of things and will never get a command line).
It's interesting how, with just three more words of information (eg,
"Control panel extension DLL" instead of just "DLL") the quesiton changes
substantially, isn't it?
.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.
-----From: "Dave Kelly"
I agree with the moderator on this one. Although if you want a stand
alone application, you cannot completely get rid of the exe, you can
reduce its size to almost nothing. Simply put everything possible
into the .EXE, and have the .EXE do one thing...call the program
stored in the .DLL.
-Dave
| Вернуться в корень Архива
|