Click to See Complete Forum and Search --> : About SHBrowseForFolder


pp_ipr
December 26th, 2004, 10:43 PM
Question about SHBrowseForFolder:
There is a folder on my PC, which's size is round about 6G.
In the SHBrowseForFolder's "Browse folder" window:
If i open this folder from My Computer->E:\->...., the browse folder window will pause about 10s.
If i open this folder from Network->... (i have shared this folder), the folder tree will be created immediately.

So i think the SHBrowseForFolder process Local path and newwork path with different method. And i have searched msdn, can't get any information.
Now, i want to implement: open from "My Computer" as fast as open from network. Anyone give me a help?
Thank u very much.

code just like below:

BROWSEINFO bi;
TCHAR szDir[MAX_PATH] = {0};
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
CString strFolder;

if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
ZeroMemory(&bi, sizeof(bi));
bi.hwndOwner = hOwner;
bi.pszDisplayName = 0;
bi.lpszTitle = lpszTips;
bi.pidlRoot = 0;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT ;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LONG)lpszDefaultPath;

pidl = SHBrowseForFolder(&bi);
if (pidl)
{
if (SHGetPathFromIDList(pidl, szDir))
{
strFolder = szDir;
}
pMalloc->Free(pidl);
pMalloc->Release();
}
}

//call back funtion
int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData)
{
TCHAR szDir[MAX_PATH];
switch(uMsg)
{
case BFFM_INITIALIZED:
{
LPCTSTR lpszDefaultPath = (LPCTSTR)pData;
if(lpszDefaultPath && lpszDefaultPath[0])
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)lpszDefaultPath);
}
else if(GetCurrentDirectory(sizeof(szDir)/sizeof(TCHAR), szDir))
{
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDir);
}
else
{
}
}
break;
case BFFM_SELCHANGED:
{
// Set the status window to the currently selected path.
if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir))
{
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir);
return 1;
}
}
break;
default:
break;
}
return 0;
}

NoHero
December 27th, 2004, 07:07 AM
Since LAN is slower than your local hard disk, the Browse Engine will look deeper into local paths to find out if he should display the "+". For such a check he needs to look deep into the path, to find out if there are any subdirectories to expand. If you open a share he will only expand and take a look at the current directory. Imagine how long it would take if you expand a 19 GB with hundred of subfolders over LAN. Horrible. :rolleyes:

pp_ipr
December 31st, 2004, 09:41 AM
Since LAN is slower than your local hard disk, the Browse Engine will look deeper into local paths to find out if he should display the "+". For such a check he needs to look deep into the path, to find out if there are any subdirectories to expand. If you open a share he will only expand and take a look at the current directory. Imagine how long it would take if you expand a 19 GB with hundred of subfolders over LAN. Horrible. :rolleyes:

Yes, sure it is. So how should i solve this problem? Can i rewrite the process when the Browse Engine looks for its subdirectories?

thanks. :)

Trasgu
December 31st, 2004, 12:25 PM
I try the code and I checked that the function BrowseCallbackProc do it more slow.
What do you get from this function?. If you like specifying the location of the root folder from which to start browsing you must set the bi.pidlRoot and to get this(a pointer to an item identifier list (PIDL)) from a string see this (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shsimpleidlistfrompath.asp).