hope_xt
路人甲
路人甲
  • 注册日期2004-04-10
  • 发帖数26
  • QQ
  • 铜币218枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1673回复:4

在Engine中如何识别Folder类型,也就是普通文件夹

楼主#
更多 发布于:2005-06-27 16:54
RT,这个问题困惑俺多时了,请各路高手指点迷津,谢谢了先!!!
喜欢0 评分0
hope_xt
cl991036
管理员
管理员
  • 注册日期2003-07-25
  • 发帖数5917
  • QQ14265545
  • 铜币29669枚
  • 威望217点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • GIS帝国铁杆
1楼#
发布于:2005-07-05 15:42
<STRONG>普通文件夹</STRONG><BR>也可以用fso控制
没钱又丑,农村户口。头可断,发型一定不能乱。 邮箱:gisempire@qq.com
举报 回复(0) 喜欢(0)     评分
hope_xt
路人甲
路人甲
  • 注册日期2004-04-10
  • 发帖数26
  • QQ
  • 铜币218枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2005-06-29 17:36
<P>谢谢谢谢楼上的啊,万分感谢</P>
hope_xt
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
3楼#
发布于:2005-06-27 19:41
<P>第二中方法</P>

<P>Option Explicit<BR>Private Declare Function GetTempFileName Lib "kernel32" Alias "GetTempFileNameA" (ByVal lpszPath As String, ByVal lpPrefixString As String, ByVal wUnique As Long, ByVal lpTempFileName As String) As Long<BR>Private Declare Function SHGetPathFromIDList Lib "Shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long<BR>Private Declare Function SHBrowseForFolder Lib "Shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long<BR>'API函数SHBrowseForFolder提供文件列表,它需要用到一个BROWSEINFO类型,此类型包括了列表框使用的参数,<BR>'此类型的声明见下面的程序,其中这里用到的几个参数简单说明一下:<BR>' 此函数返回值是指向项目(ITEM)的一个指针,有了这个数值,再用API函数SHGetPathFromIDList可以获得具体的路径,如果用户按的是“取消”按钮,则返回值为NULL。<BR>Private Type BROWSEINFO<BR>hOwner As Long '当前窗口的句柄。<BR>pidlRoot As Long 'pidlRoot—从何根路径开始展开文件夹,缺省情况下从“桌面”开始展开。<BR>pszDisplayName As String<BR>lpszTitle As String 'lpszTitle—目录树上方的标题,用来给用户一些提示信息。<BR>ulFlags As Long 'ulFlags—显示标志控制项:比如若赋值为<BR>' BIF_BROWSEFORCOMPUTER,则只有当用户选择“我的电脑”时“确定”按钮才有效,<BR>' 这里我们需要的是BIF_RETURNONLYFSDIRS,只有用户选择的是文件夹时“确定”按钮才有效。<BR>lpfn As Long<BR>lParam As Long<BR>iImage As Long<BR>End Type<BR>Const BIF_RETURNONLYFSDIRS = ;H1<BR><BR>Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _<BR>"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long<BR>Type OPENFILENAME<BR>lStructSize As Long<BR>hwndOwner As Long<BR>hInstance As Long<BR>lpstrFilter As String<BR>lpstrCustomFilter As String<BR>nMaxCustFilter As Long<BR>nFilterIndex As Long<BR>lpstrFile As String<BR>nMaxFile As Long<BR>lpstrFileTitle As String<BR>nMaxFileTitle As Long<BR>lpstrInitialDir As String<BR>lpstrTitle As String<BR>flags As Long<BR>nFileOffset As Integer<BR>nFileExtension As Integer<BR>lpstrDefExt As String<BR>lCustData As Long<BR>lpfnHook As Long<BR>lpTemplateName As String<BR>End Type<BR><BR><BR><BR>Public Function GetPath(hwnd As Long) As String<BR>Dim bi As BROWSEINFO '声明必要的变量<BR>Dim rtn$, pidl$, path$, pos%, t, SpecIn, SpecOut<BR>bi.hOwner = hwnd '使对话框处于屏幕中心<BR>bi.lpszTitle = "选择目录..." '设置标题文字<BR>bi.ulFlags = BIF_RETURNONLYFSDIRS '返回文件夹的类型<BR>pidl$ = SHBrowseForFolder(bi) '显示对话框<BR>path = Space(512) '设置字符数的最大值<BR>t = SHGetPathFromIDList(ByVal pidl$, ByVal path) '获得所选的路径<BR>pos% = InStr(path$, Chr$(0)) '从字符串中提取路径<BR>SpecIn = Left(path$, pos - 1)<BR>If Right$(SpecIn, 1) = "\" Then<BR>SpecOut = SpecIn<BR>Else<BR>SpecOut = SpecIn + "\"<BR>End If<BR>GetPath = SpecOut<BR>End Function<BR><BR>Public Function GetFile(hwnd As Long) As String<BR>Dim ofn As OPENFILENAME<BR>Dim rtn As String<BR>ofn.lStructSize = Len(ofn)<BR>ofn.hwndOwner = hwnd<BR>ofn.hInstance = App.hInstance<BR>ofn.lpstrFilter = "所有文件"<BR>ofn.lpstrFile = Space(254)<BR>ofn.nMaxFile = 255<BR>ofn.lpstrFileTitle = Space(254)<BR>ofn.nMaxFileTitle = 255<BR>ofn.lpstrInitialDir = App.path<BR>ofn.lpstrTitle = "打开文件"<BR>ofn.flags = 6148<BR>rtn = GetOpenFileName(ofn)<BR>If rtn >= 1 Then<BR>GetFile = ofn.lpstrFile<BR>Else<BR>GetFile = ""<BR>End If<BR>En </P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
4楼#
发布于:2005-06-27 19:40
'把下面的代码放入一个标准模块中<BR>Option Explicit<BR>Public Type BrowseInfo<BR>        hwndOwner As Long<BR>        pIDLRoot As Long<BR>        pszDisplayName As Long<BR>        lpszTitle As Long<BR>        ulFlags As Long<BR>        lpfnCallback As Long<BR>        lParam As Long<BR>        iImage As Long<BR>End Type<BR>Public Const BIF_RETURNONLYFSDIRS = 1<BR>Public Const MAX_PATH = 260<BR>Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)<BR>Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long<BR>Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long<BR>Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long<BR>'下面这个函数的返回值就是选择的文件夹<BR>Public Function BrowseForFolder(hwndOwner As Long, sPrompt As String) As String<BR>        Dim iNull As Integer<BR>        Dim lpIDList As Long<BR>        Dim lResult As Long<BR>        Dim sPath As String<BR>        Dim udtBI As BrowseInfo<BR>        With udtBI<BR>                .hwndOwner = hwndOwner<BR>                .lpszTitle = lstrcat(sPrompt, "")<BR>                .ulFlags = BIF_RETURNONLYFSDIRS<BR>        End With<BR>        lpIDList = SHBrowseForFolder(udtBI)<BR>        If lpIDList Then<BR>                sPath = String$(MAX_PATH, 0)<BR>                lResult = SHGetPathFromIDList(lpIDList, sPath)<BR>                Call CoTaskMemFree(lpIDList)<BR>                iNull = InStr(sPath, vbNullChar)<BR>                If iNull Then sPath = Left$(sPath, iNull - 1)<BR>        End If<BR>        BrowseForFolder = sPath<BR>End Function <BR><BR>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
游客

返回顶部