这次满足你的要求了,<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls, shlobj; //注意这里shlobj<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> lpbi: BROWSEINFO;<br> pidlStart: PItemIDList;<br> pszPath: array[0..MAX_PATH] of Char;<br> pidlResult: PItemIDList;<br> sResult: string;<br>begin<br> SHGetSpecialFolderLocation(Handle, 0, pidlStart);<br> with lpbi do<br> begin<br> hwndOwner := Handle;<br> pszDisplayName := pszPath;<br> lpszTitle := PChar('请选择路径:');<br> ulFlags := BIF_RETURNONLYFSDIRS;<br> pidlRoot := pidlStart;<br> lpfn := nil;<br> end;<br> pidlResult := SHBrowseForFolder(lpbi);<br> if SHGetPathFromIDList(pidlResult, pszPath) then<br> sResult := StrPas(pszPath);<br>end;<br><br>end.<br>