Thursday, June 21, 2007

Delphi Tips And Tricks: CoInitialize/CoUninitialize Part IIb

I forgot to mention in Part II that a very simple call stack containing code like this:


CoInitializeEx(nil, COINIT_APARTMENTTHREADED)
CoInitializeEx(nil, COINIT_MULTITHREADED)
CoUninitialize;
CoUninitialize;


will cause one too many calls to CoUninitialize. The second call to CoInitializeEx will return RPC_E_CHANGED_MODE and does not require another call to CoUninitialize because the internal reference counting of CoInitialize didn't increment. The example I provided in Part II demonstrated this but I neglected to mention it specifically.

I just wanted to mention this before I forgot. Next post about CoInitialize will be as requested a multithreaded example.

No comments:

Post a Comment