* Dave Angel:
I'm not talking about COM servers, which run in a separate process.
Only about calling functionality that happens to be encoded in an .EXE
file.
You're trying to generalize what I said. I never said you could call
into any .EXE file, just that calling into one is not infeasible.
Well, true. And I'm sorry if my reply sounded as a misrepresentation. I haven't
tried this calling-a-function-in-an-exe (since 16-bit Windows, that is!, but
that was very different), but I can imagine two such cases:
(1) a function f is exported by the EXE, and f doesn't depend on anything
but its arguments and does not use any static storage, or
(2) a DLL loaded by the EXE calls back into the EXE, which could work
because then everything's initialized (however, there are better ways).
But these are very special cases where one really has to know what one is doing.
As Gabriel Genellina wrote up-thread, "you *could* do that if you work hard
enough, but that's not how things are usually done".
That said, in Windows the least uncommon reason to load an EXE as a DLL is, IME,
to access resource data in the EXE. Tip for that: the module handle, casted to
appropriate pointer type, points to the start of the loaded image (great for
accessing e.g. version info resource). I think this is still undocumented...
You're describing using an .EXE written using the Microsoft C compiler
and/or libraries, not a Windows .EXE in general. In any case, whenever
you link to a module written in a different environment, you'll have
restrictions. Chief among them is the use of a compatible memory model,
the stack conventions, the allocators, and so on.. Solving the thread
issue is probably the easiest one to fix.
I'm not recommending it, just refuting the "not supposed to" quote above.
Again, I'm sorry if my reply sounded as a misrepresentation.
I just tried to make the solution-constraining technical facts available,
addressing Mike's "making the direct use of an EXE API's a routine task".
I think we're all in (violent?) agreement on this.
Cheers,
- Alf