uses ShellAPI, ShlObj; <br> <br> procedure TForm1.Button1Click(Sender: TObject); <br> var <br> TitleName : string; <br> lpItemID : PItemIDList; <br> BrowseInfo : TBrowseInfo; <br> DisplayName : array[0..MAX_PATH] of char; <br> TempPath : array[0..MAX_PATH] of char; <br> begin <br> FillChar(BrowseInfo, sizeof(TBrowseInfo), #0); <br> BrowseInfo.hwndOwner := Form1.Handle; <br> BrowseInfo.pszDisplayName := @DisplayName; <br> TitleName := 'Please specify a directory'; <br> BrowseInfo.lpszTitle := PChar(TitleName); <br> BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS; <br> lpItemID := SHBrowseForFolder(BrowseInfo); <br> if lpItemId <> nil then begin <br> SHGetPathFromIDList(lpItemID, TempPath); <br> ShowMessage(TempPath); <br> GlobalFreePtr(lpItemID); <br> end; <br> end; <br>