BROWSEINFO BIF_SHAREABLE flag problem using SHBrowseForFolder

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p align=left><font face="Times New Roman" size=3>Hello all,</font>
<p align=left><font face="Times New Roman" size=3></font> 
<p align=left><font face="Times New Roman" size=3>I am new to these forums so I hope I have chosen the right place to post this.  I am using C++ so this seems like the right place although maybe platform SDK is the right place.  Sorry if this is not right.</font>
<p align=left><font face="Times New Roman" size=3></font> 
<font face="Times New Roman <font size=3>Anyway, I am using the SHBrowseForFolder function to allow a user to select a folder to output data to and I have come across a problem using the BIF_SHAREABLE flag which I set in the BROWSEINFO  structure which is a passed into the SHBrowseForFolder function .  According to the documentation here </font><a title="http://msdn2.microsoft.com/en-us/library/ms538017.aspx http://msdn2.microsoft.com/en-us/library/ms538017.aspx <font size=3>http://msdn2.microsoft.com/en-us/library/ms538017.aspx</font> <font size=3> setting this flag will allow the browse dialog box to display shareable resources on remote systems.  However, in the testing I have done this flag seems to work the opposite way that it is supposed to according to how I interpreted the documentation.</font></font>
<p align=left><font face="Times New Roman" size=3></font> 
<font face="Times New Roman" size=3>On some of my test machines (Windows XP Pro and Home which both have Version 5 or 6 of the DLL called) I have network drives mapped to drive letters and if they are disconnected then with the BIF_SHAREABLE flag set they will show up in the browse list but if they are connected then they do not show up anymore .  If I dont set the  BIF_SHAREABLE flag then all of the mapped drives end up showing up which seems like the opposite behavior I would expect.</font>
<p align=left><font face="Times New Roman" size=3></font> 
<font face="Times New Roman" size=3>Here is a portion of the code that is relevant in case it will help:</font> <font face="Times New Roman" size=3>
<p align=left>
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100% Code Snippet <font face="Times New Roman" size=3>
<p align=left> BROWSEINFO bi;
 LPITEMIDLIST pidlBrowse; // PIDL selected by user
 LPMALLOC pMalloc;
 tstr titlestr = GetResourceStr(title);
 TCHAR pathwork[_MAX_PATH];</font>
<p align=left><font face="Times New Roman" size=3></font> 
<p align=left><font face="Times New Roman" size=3> int version = GetDLLVersion(_T("SHELL32.DLL"));
 SHGetMalloc(&pMalloc);</font>
<p align=left><font face="Times New Roman" size=3> memset(&bi,0,sizeof bi);
 bi.hwndOwner = hDlg;
 bi.pidlRoot = NULL;
 bi.pszDisplayName = pathwork;
 bi.lpszTitle = titlestr.c_str();</font> <font face="Times New Roman" size=3>
<p align=left>
 bi.ulFlags = BIF_RETURNONLYFSDIRS;
 if (version >= 0x50000)
     bi.ulFlags |= BIF_NEWDIALOGSTYLE | BIF_SHAREABLE;  </font>
<p align=left><font face="Times New Roman" size=3></font> 
<p align=left><font face="Times New Roman" size=3> bi.lpfn = BrowseCallbackProc;
 bi.lParam = (long)pathwork;</font>
<p align=left><font face="Times New Roman" size=3></font> 
<p align=left><font face="Times New Roman" size=3> // Browse for a folder and return its PIDL.
 pidlBrowse = SHBrowseForFolder(&bi);</font>
<p align=left> 
<p align=left>  </font>

<p align=left><font face="Times New Roman" size=3>
</font>
<font size=3></font> 
<font size=3>For now I have just commented out the BIF_SHAREABLE flag which gives me the behavior I want and expect but I would like to understand why the function is acting this way.  I am just overlooking something simple?</font>

View the full article
 
Back
Top