Ok to call CoInitialize in the file dialogs?

Robert Shearman rob at codeweavers.com
Tue Nov 8 15:16:42 CST 2005


Michael Jung wrote:

>Hi Rob,
>
>On Tuesday 08 November 2005 19:59, Robert Shearman wrote:
>  
>
>>The only objection is that in general it is bad to force a threading
>>model and that the caller should be the one specifying it. 
>>    
>>
>
>I guess that's not a problem.
>
>If COM isn't initialized prior to the call to SHBrowseForFolder it will also 
>be uninitialized after the call. The caller can then call CoInitializeEx 
>afterwards (I'm assuming here that it's ok to do 
>CoInitializeEx(COINIT_APARTMENTTHREADED, NULL); CoUnintialize(); 
>CoInitializeEx(COINIT_MULTITHREADED, NULL); Is that correct?).
>
>If COM is already initialized with the same threading model as specified in 
>SHBrowseForFolder's CoInitializeEx, it will succeed with S_FALSE.
>
>If COM is already initialized with a different threading model, CoInitializeEx 
>will fail. But then, it's already initialized anyway and everything is fine. 
>And we won't call CoUninitialize before returning from SHBrowseForFolder in 
>this case.
>
>Did I understand this stuff correctly?
>  
>

Yes. That is all correct.

>Thanks for your reply.
>  
>

-- 
Rob Shearman




More information about the wine-devel mailing list