求寻一个WINAPI函数

summe 2002-08-30 10:01:06
记得我们编程的时候,有许多时候需要用到打开一个窗口,来定位目录路径,windows系统中常有这样的操作,我以前是自己做一个from,然后自己在里面加各种控件来调用实现,也可以用delphi提供的dialog对话框来完成,
我想问的是,我记得在以前看过一个winapi函数,直接提供一个窗口,供你选择目标目录;请教各位,那个函数是什么啊??

它调用后出现一个很简单的对话框式的窗体,一个目录树,然后是确定
...全文
59 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
starcbh 2002-11-06
  • 打赏
  • 举报
回复
这个是WinAPI???

有没有搞错
summe 2002-08-31
  • 打赏
  • 举报
回复
嗯;昨天晚上我已经找到了;就是selectDirectory();它有两种用法,可以得到那个框框,谢谢大家了
wetrust 2002-08-30
  • 打赏
  • 举报
回复
应该是这个(另一个是英文界面,平时也不会用的):

extern PACKAGE bool __fastcall SelectDirectory(constAnsiString Caption, const WideString Root, AnsiString &Directory);

Description

Call SelectDirectory to let the user enter a directory name.

Use the first syntax to display the Windows directory browser. The Caption parameter specifies a caption for the dialog. The Root parameter specifies the root directory from which to browse. The selected directory is returned as the Directory parameter. When using this syntax, SelectDirectory does not change the value of the current directory.

Warning: You can抰 use the same variable for the Root parameter and the Directory parameter.

Use the second syntax to call the Select Directory dialog box. The directory passed to the function with the Directory parameter appears as the currently selected directory when the dialog box appears. The name of the directory the user selects becomes the value of Directory when the function returns.

The HelpCtx parameter is the help context ID number.

The Options parameter is a set of values. If Options is the empty set, the user can only select a directory that already exists. No edit box is provided for the user to enter a new directory name. If Options is not empty, the included values determine how the dialog responds when the user types a nonexistent directory name.

With either syntax, SelectDirectory returns true if the user selected a directory and chose OK, and false if the user chose Cancel or closed the dialog box without selecting a directory.
shuixin13 2002-08-30
  • 打赏
  • 举报
回复
顶一下下
Kingron 2002-08-30
  • 打赏
  • 举报
回复
K,就是那个SelectDirectory(),这个函数是Overload的,你注意使用第二个即可!uses filectrl先……
summe 2002-08-30
  • 打赏
  • 举报
回复
http://www.yesue.com/question/show.asp?id=787&catalog=Q_Program_General
summe 2002-08-30
  • 打赏
  • 举报
回复



编程中需要得到一个自选择的目录;一般是调用某个对方框窗口控件;或者自己做一个窗体来实现地址传递,但是,我记得微软提供了一个函数,可以直接出现一个选择目录窗口,界面很简单,就是一个目录树和两个确定取消按钮,这个窗口在windows中随处可以遇到,可我就是忘记这个函数是什么了;哪位大侠能告诉我???


win2000中那目录浏览框中多了个新建目录的按钮;老的没有,不过肯定也是微软的一个函数,



在网上邻居中点击右键选择映射一个网络驱动器,然后选择那个 【浏览(b)】按钮;出来的那个窗口就是
summe 2002-08-30
  • 打赏
  • 举报
回复
天哪;还是不对阿;各位就很支持;非常感谢,可是那就一个函数,非常简单,可是我就是实在想不到它是什么了;

并不是各位告诉我的解决方法,我要的是那个函数
9igogo 2002-08-30
  • 打赏
  • 举报
回复
mark
starcbh 2002-08-30
  • 打赏
  • 举报
回复
Pb用法:

browseinfo lstr_bi
itemidlist lstr_idl
unsignedlong ll_pidl
unsignedlong ll_r
Integer li_pos
String ls_Path
unsignedlong ll_Null
SetNull( ll_Null )
lstr_bi.hOwner = Handle( awi_Parent )
lstr_bi.pidlRoot = 0
lstr_bi.lpszTitle = as_caption
lstr_bi.ulFlags = bif_ReturnOnlyFSDirs
lstr_bi.pszDisplayName = Space( 255 )
lstr_bi.lpfn = ll_Null
ll_pidl = SHBrowseForFolderA( lstr_bi )
ls_Path = Space( 255 )
ll_R = SHGetPathFromIDListA( ll_pidl, ls_Path )
CoTaskMemFree( ll_pidl )
RETURN ls_Path
starcbh 2002-08-30
  • 打赏
  • 举报
回复
unsignedlong SHGetPathFromIDListA 'shell32'
unsignedlong SHBrowseForFolderA 'shell32'
summe 2002-08-30
  • 打赏
  • 举报
回复
对不住;这是你自己写的吧;非常抱歉,微软已经提供了这样的一个函数了;可以直接用的;不需要自己写;我想找的就是那个东东
greenspan 2002-08-30
  • 打赏
  • 举报
回复
uses
ShlObj,Windows;
greenspan 2002-08-30
  • 打赏
  • 举报
回复
function ShowSelectFolder(const Handle:THandle;const FilePosition:TFilePosition;const Title:string;var Path:string):Boolean;
const
nFolder:Array[TFilePosition]of Integer = (CSIDL_DRIVES,CSIDL_NETHOOD);
var
BrowseInfo : TBrowseInfo;
ItemIDList : PItemIDList;
// AFolder : array[0..MAX_PATH-1] of char;
APath : array[0..MAX_PATH-1] of char;
begin
SHGetSpecialFolderLocation(Handle,nFolder[FilePosition], ItemIdList);
FillChar(BrowseInfo,SizeOf(TBrowseInfo),0);
with BrowseInfo do
begin
hwndOwner := Handle;
pidlRoot := ItemIDList;
pszDisplayName := nil;
lpszTitle := PChar(Title);
ulFlags := BIF_RETURNONLYFSDIRS;
end;
ItemIDList := SHBrowseForFolder(BrowseInfo);
Result := Assigned(ItemIDList) and SHGetPathFromIDList(ItemIDList,APath);
Path := APath;

end;
summe 2002-08-30
  • 打赏
  • 举报
回复
先谢谢楼上那位,我们继续
对于你刚刚说道的函数我试过了;
代码如下
procedure TForm1.Button1Click(Sender: TObject);
var Dir:String;
begin
if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP) then
Label1.Caption := Dir;

end;

出现的窗口是一个有着驱动器选择的COMBOBOX的控件,一个目录树,一个文件显示区及一个文件路径显示编辑框,类似于win31的那种界面,

呵呵;可我还是要找另外的,那个窗口类似于:当你在delphi中配置Environment Options 时,打开library配置页,打开目录浏览后,出现的那个窗口,很简单SelectDirectory不像那么复杂。


哪位高手还有指教的??

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧