Sorry for the late reply!

You basically have two options:

1. Initialize it in your "init" function, and uninitialize it in your
"exit" function.  Of course your DLL may not have an "init" and/or
"exit" function, so this may not be an option.

2. Something like this:

class COMInitializer
{
 private:
  COMInitializer() {
   ::CoInitialize( ... );
  }
  ~COMInitializer() {
   ::CoUninitialize( ... );
  }

 public:
  static COMInitializer & EnsureInitialized() {
   static COMInitializer initializer;
   return initializer;
  }
};

And then, in every function which uses COM, do something like:

void f() {
 COMInitializer::EnsureInitialized();

 // go on and use COM
}

Hope this helps,
Ehsan

jtroxas wrote:
> hello where is the best place to call CoInitiallize\CoUnInitialize on a
> DLL..
> 
> msdn says not to call it on DLLMain..
> 
> My DLL is an in-process shell extension DLL... can anybody help..
> 
> 
> 
> 
> _______________________________________________
> msvc mailing list
> [email protected]
> See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for 
> subscription changes, and list archive.
> 
> 
> 


Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
msvc mailing list
[email protected]
See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for 
subscription changes, and list archive.

Reply via email to