I'm new in ATL business, and I'm sorry if I use incorrect terms. I'm facing
a problem with ATL object in dll. I've written both dll and activeX-server,
but I don't have access to source code of the program that is using this
I've been searching information about how to uninitialize COM library in
dll. I noticed, that you can't call CoInitialize and CoUninitialize them
from DllMain, and I found a way to initialize it. How can I uninitialize it
when dll is no longer used? Only logical way I can think of is to do it in
DllMain in DLL_PROCESS_DETACH.
Can someone help me?
> I've been searching information about how to uninitialize COM library in
You shouldn't. In order to get anywhere close to your DLL, the client must
already have called CoInitialize, since it generally uses the COM run-time
to activate objects inside it.
The exception is DLLs which are creating threads - those must join an
apartment - but that is generally frowned upon anyway.
So, clients must call CoInitialize and CoUninitialize once per thread.
Hope that helps.
To the OP: your client must call initialization and uninitialization
functions exported by your DLL. Depending on the thread
organization within the client and where are you to be called,
you may have to do different things in your DLL, perhaps even
spawining a thread and doing all COM activity from within it...
"Kim Gräsman" <k...@mvps.org> wrote in message news:eT9ytt$vDHA...@tk2msftngp13.phx.gbl...
The problem here is, that I can't change client program to call
initialization and uninitialization functions because program is already
done by different company. I had to create fake-dll that uses real dll
through ATL COM server. This is done because only one instance of (real)dll
is allowed, and it is used by three different clients.
"Alexander Nickolov" <agnic...@mvps.org> wrote in message
> The problem here is, that I can't change client program to call
> initialization and uninitialization functions because program is already
> done by different company.
In that case, you should probably spawn a thread as suggested by Alexander.
That way, you can guarantee that your COM object's threading requirements
Of course, it depends on what the COM object does, and what its threading
Thank you both for answers. Problem is now solved.
"Kim Gräsman" <k...@mvps.org> wrote in message