参数winhandle:调用窗体句柄;title:对话框标题

function BrowseForComputer(const winhandle : THANDLE; const title : string) : string;
  //Pop up the standard ‘Browse for computer’ dialog box
  var
    BrowseInfo: TBrowseInfo;
    IDRoot: PItemIDList;
    Path: array[0..MAX_PATH] of Char;
  begin
    // Get the Item ID for Network Neighborhood
    SHGetSpecialFolderLocation(winHandle, CSIDL_NETWORK, IDRoot);
    ZeroMemory(@BrowseInfo, SizeOf(TBrowseInfo));
    ZeroMemory(@path, MAX_PATH);
    BrowseInfo.hwndOwner := winhandle;
    BrowseInfo.pidlRoot := IDRoot;
    BrowseInfo.lpszTitle := PChar(title);
    BrowseInfo.pszDisplayName := @path;
    // Include this flag to show computer only
    BrowseInfo.ulFlags := BIF_BROWSEFORCOMPUTER;// or BIF_RETURNONLYFSDIRS   ;
    // Show the browse dialog, get the Item ID for the selected item and convert it to a path
    SHBrowseForFolder(BrowseInfo);
  //  SHGetPathFromIDList(IDList, Path);
    result := path;
  end;


评论

该日志第一篇评论

发表评论

评论也有版权!