I had done this in VC++ years back.
Is your language in VC++ or C#.NET?.
Tom
See a
sample code specially the one in Bold in VC++.. Hope this helps..
CXSBrowseFolder::retCode CXSBrowseFolder::Show(HWND parent, LPSTR pathBuffer)
{
// Passed in a NULL pointer (!)
ASSERT(pathBuffer);
if (!pathBuffer)
return RET_NOPATH;
// Return value for the function
retCode ret = RET_OK;
LPITEMIDLIST itemIDList;
// Set up the params
BROWSEINFO browseInfo;
// The dialog must have
a parent
ASSERT(parent);
browseInfo.hwndOwner = parent;
browseInfo.pidlRoot = m_root;
browseInfo.pszDisplayName = m_displayName;
browseInfo.lpszTitle =
m_title;
browseInfo.ulFlags = m_style;
browseInfo.lpfn = NULL;
browseInfo.lParam
= 0;
// Show the dialog
itemIDList = SHBrowseForFolder
(&browseInfo);
// Did user press cancel?
if (!itemIDList)
ret =
RET_CANCEL;
// Is everything so far?
if (ret != RET_CANCEL) {
// Get the path from the returned ITEMIDLIST
if (!SHGetPathFromIDList(itemIDList, pathBuffer))
ret = RET_NOPATH;
// Now we need to free
the ITEMIDLIST the shell allocated
LPMALLOC shellMalloc;
HRESULT hr;
// Get pointer to the shell's malloc interface
hr = SHGetMalloc(&shellMalloc);
// Did it work?
if
(SUCCEEDED(hr)) {
// Free the shell's memory
shellMalloc->Free(itemIDList);
// Release the interface
shellMalloc->Release();
}
}
return ret;
}
Share this page across other social networking sites