//---------------------------------------------------------------------------<br>#define NO_WIN32_LEAN_AND_MEAN /*注意此处*/<br>#include 《vcl.h》<br>#pragma hdrstop<br><br>#include "shlobj.h" <br>#include "Unit1.h"<br>//---------------------------------------------------------------------------<br>#pragma package(smart_init)<br>#pragma resource "*.dfm"<br>TForm1 *Form1;<br>//---------------------------------------------------------------------------<br>__fastcall TForm1::TForm1(TComponent* Owner)<br> : TForm(Owner)<br>{<br>}<br>//---------------------------------------------------------------------------<br><br>void __fastcall TForm1::Button1Click(TObject *Sender)<br>{<br> BROWSEINFOA bi;<br> char WDir[MAX_PATH];<br> LPITEMIDLIST ItemID;<br> memset(&bi, 0, sizeof(BROWSEINFOA));<br> memset(WDir, 0, MAX_PATH);<br> bi.hwndOwner = Handle;<br> bi.ulFlags = BIF_RETURNONLYFSDIRS;<br> bi.lpszTitle = "请选择路径:";<br> ItemID = SHBrowseForFolder(&bi);<br> SHGetPathFromIDList(ItemID, WDir);<br> Edit1->Text = String(WDir); <br>}<br>//---------------------------------------------------------------------------<br>