各位,那个在shell里,可以弹出窗口,让你选择目录的api是什么来着?我找来半天没找到(0分)

  • 主题发起人 主题发起人 阿魁
  • 开始时间 开始时间
Unit<br><br>FileCtrl<br><br>Category<br><br>dialog and message routines<br><br>function SelectDirectory(const Caption: string; const Root: WideString; out Directory: string): Boolean; overload;<br>function SelectDirectory(var Directory: string; Options: TSelectDirOpts; HelpCtx: Longint): Boolean; overload;<br><br>Description<br><br>Call SelectDirectory to let the user enter a directory name. <br>行不行?<br>给点分嘛:)
 
不行啊,界面太难看了,还是英文的。<br>我记得有个API可以提供这个功能。
 
哦?就是上面那个吖,你再追追源代码看看,是不同的两个来的。[:)]
 
怎么说是英文的?试试下面:<br>uses<br>ShellApi;<br>...<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; s: string;<br>begin<br>if SelectDirectory('请选择文件夹','',S) then<br>&nbsp; &nbsp;showmessage(s);<br>end;<br>不过还得注意得到的路径如果是根目录最后有'/'.
 
就是这两个,顺便问一下,能不能控制窗口弹出的位置<br>我用他弹出的窗口总在我程序的右下方,比较难看<br>
 
你可以看看他实际调用的API,或许可以搞搞吧。。
 
uses ShellAPI, ShlObj; <br>&nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; procedure TForm1.Button1Click(Sender: TObject); <br>&nbsp; &nbsp; var <br>&nbsp; &nbsp; &nbsp;TitleName : string; <br>&nbsp; &nbsp; &nbsp;lpItemID : PItemIDList; <br>&nbsp; &nbsp; &nbsp;BrowseInfo : TBrowseInfo; <br>&nbsp; &nbsp; &nbsp;DisplayName : array[0..MAX_PATH] of char; <br>&nbsp; &nbsp; &nbsp;TempPath : array[0..MAX_PATH] of char; <br>&nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp;FillChar(BrowseInfo, sizeof(TBrowseInfo), #0); <br>&nbsp; &nbsp; &nbsp;BrowseInfo.hwndOwner := Form1.Handle; <br>&nbsp; &nbsp; &nbsp;BrowseInfo.pszDisplayName := @DisplayName; <br>&nbsp; &nbsp; &nbsp;TitleName := 'Please specify a directory'; <br>&nbsp; &nbsp; &nbsp;BrowseInfo.lpszTitle := PChar(TitleName); <br>&nbsp; &nbsp; &nbsp;BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS; <br>&nbsp; &nbsp; &nbsp;lpItemID := SHBrowseForFolder(BrowseInfo); <br>&nbsp; &nbsp; &nbsp;if lpItemId &lt;&gt; nil then begin <br>&nbsp; &nbsp; &nbsp;SHGetPathFromIDList(lpItemID, TempPath); <br>&nbsp; &nbsp; &nbsp;ShowMessage(TempPath); <br>&nbsp; &nbsp; &nbsp;GlobalFreePtr(lpItemID); <br>&nbsp; &nbsp; &nbsp;end; <br>&nbsp; &nbsp; end; <br>
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部