SHBrowseForFolder
转载 演示SHBrowseForFolder用法
/********************************************************************
created: 2008/04/24
created: 24:4:2008 12:47
author: Gohan
http://feed.feedsky.com/gohan
purpose: 演示SHBrowseForFolder用法
*********************************************************************/
#include <Windows.h>
#include <ShlObj.h>
int main()
{
BROWSEINFO bi;
ZeroMemory(&bi,sizeof(BROWSEINFO));
LPMALLOC pMalloc;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
TCHAR * path = new TCHAR[MAX_PATH];
if(pidl != NULL)
{
SHGetPathFromIDList(pidl,path);
MessageBox(NULL,path,TEXT("Choose"),MB_OK);
if(SUCCEEDED(SHGetMalloc(&pMalloc)))//pidl指向的对象用完应该释放,之前忽略了
{
pMalloc->Free(pidl);
pMalloc->Release();
}
}
else
{
MessageBox(NULL,TEXT("选择为空"),TEXT("Choose"),MB_OK);
}
delete path;
}
本文采用 知识共享署名 4.0 国际许可协议 进行许可