Ok to call CoInitialize in the file dialogs?

Michael Jung mjung at iss.tu-darmstadt.de
Tue Nov 8 11:44:52 CST 2005


Hi all,

Some shell namespace extensions only work if COM is initialized (For instance 
the brand-new shell instance objects ;) Go download the free (as in beer) 
Shell Object Editor from www.tropictech.de if you want to try them.). On 
WinXP those work without the application calling CoInitialize in 
SHBrowseForFolder and in the file dialogs. I assume this means there is a 
CoInitialize/CoUninitialize pair guarding SHBrowseForFolder.

For the attached browse.c test program (meant to be compiled with borland's 
free compiler - sorry) on can browse into shell instance objects on winxp, 
but the call to GetDisplayNameOf fails with CO_E_NOTINITIALIZED. This means 
COM is initialized inside SHBrowseForFolder, but un-initialized after the 
call returns. If you remove the '//' in front of the CoInitialize call and 
compile again, GetDisplayNameOf succeeds.

On wine, you can't currently browse into shell instance objects, if COM is not 
initialized. If you add CoInitialize/CoUninitialize to SHBrowseForFolder (see 
attached patch), it exhibits the same behaviour as winxp.

How expensive is COM un-/initialization? Any objections against adding 
CoInitialize/CoUnitialize to SHBrowseForFolder and the file dialogs?

Bye,
-- 
Michael Jung
mjung at iss.tu-darmstadt.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dlls_shell32_brsfolder_c.diff
Type: text/x-diff
Size: 812 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20051108/bcdc8ea8/dlls_shell32_brsfolder_c-0002.diff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: browse.c
Type: text/x-csrc
Size: 1511 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20051108/bcdc8ea8/browse-0002.c


More information about the wine-devel mailing list