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