#define NO_WIN32_LEAN_AND_MEAN 
#include <shlobj.h>
#include <vcl.h>//以上这三个要放在.cpp文件的最上边

//---------------------------------------------------------------------------

#include <shlobj.h>

bool __fastcall CrnBrowserDir(HANDLE hWin, LPSTR lpCaption, LPSTR lpDir, LPSTR lpDispName)
{
BROWSEINFO bi;
LPITEMIDLIST pidl;
LPMALLOC pShellMalloc;
bool bRet = false;

if(SHGetMalloc(&pShellMalloc) == NO_ERROR)
{
memset(&bi, 0x00, sizeof(bi));
bi.hwndOwner = hWin; // Owner window
bi.pidlRoot = 0; // root folder
bi.pszDisplayName = lpDispName; // return display name
bi.lpszTitle = lpCaption; // label caption
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; // config flags
bi.lpfn = 0; // callback function

pidl = SHBrowseForFolder(&bi);
if(pidl)
{
if(SHGetPathFromIDList(pidl, lpDir))
bRet = true;

pShellMalloc->Free(pidl);
}
pShellMalloc->Release();
}
return bRet;
}
//---------------------------------------------------------------------------
// 调用代码:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char lpDir[MAX_PATH];
char lpDispName[MAX_PATH];
bool bRet = CrnBrowserDir(Handle, "请选择一个文件夹:", lpDir, lpDispName);
if(bRet)
ShowMessage(String("选择的文件夹是: ") + String(lpDir) + String("\r\n")
+ String("显示名称是: ") + String(lpDispName));
else
ShowMessage("没有选择文件夹!");
}


黑色头发:http://heisetoufa.iteye.com/