
retrieve directory (not file) info with an API (WinnNT4.0)
Much thanks,
this is exactly what I needed.
Alain.
Quote:
>-----Original Message-----
>Alain,
>(Think i first found this code on Dev Ashishs website)
>Paste the following into a module and use the function
fDialog to
>call the explorer dialog. Believe the first two variables
in the call
>should be set to true for directory only...
>' General Errors
>Public Const adhcAccErrSuccess = 0
>Public Const adhcAccErrUnknown = -1
>' Common Dialogs
>' GetFileName errors
>Public Const adhcAccErrGFNCantOpenDialog = -301
>Public Const adhcAccErrGFNUserCancelledDialog = -302
>' GetFileNameInfo flags
>Public Const adhcGfniConfirmReplace = &H1 '
Prompt if
>overwriting a file?
>Public Const adhcGfniNoChangeDir = &H2 '
Disable the
>read-only option
>Public Const adhcGfniAllowReadOnly =
&H4 ' Don't
Quote:
>change to the directory the user selected?
>Public Const adhcGfniAllowMultiSelect = &H8 '
Allow
>multiple-selection?
>Public Const adhcGfniDirectoryOnly = &H20 '
Open as
>directory picker?
>Public Const adhcGfniInitializeView = &H40 '
Initialize
>the view to the lView member or use last selected view?
>' Views in the Office Find File dialog
>Public Const adhcGfniViewDetails = 0 '
Details
>Public Const adhcGfniViewPreview = 1 '
Preview
>Public Const adhcGfniViewProperties = 2 '
Properties
>Public Const adhcGfniViewList = 3 '
List
>(typical)
>Type adh_accOfficeGetFileNameInfo
> hwndOwner As Long
> strAppName As String * 255
> strDlgTitle As String * 255
> strOpenTitle As String * 255
> strFile As String * 4096
> strInitialDir As String * 255
> strFilter As String * 255
> lngFilterIndex As Long
> lngView As Long
> lngFlags As Long
>End Type
>Declare Function adh_accOfficeGetFileName
Lib "msaccess.exe" _
Quote:
> Alias "#56" (gfni As adh_accOfficeGetFileNameInfo, ByVal
fOpen As
>Integer) As Long
>Public Function fDialog(booOpen As Boolean, _
> booDirOnly As Boolean, _
> Optional strDialogTitle As
String, _
> Optional strButtonText As String,
_
> Optional strInitDir As String, _
> Optional strFilters As String) As
String
>'on error GoTo err_handle
>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''
Quote:
>'STANDARD FILE OPEN/SAVE DIALOG USED IN OFFICE
>'---------------------------------------------------------
------------------------------------
Quote:
>'EXAMPLE CALL
>'Me!txtText = fDialog(True, False, "File Open
Dialog", "Open File", ,
Quote:
>"Database File (*.mdb)")
>'---------------------------------------------------------
------------------------------------
Quote:
>'AVAILABLE FILTERS
>'DELIMITED BY '|'
>'HTML (*.html;*.htm)
>'HTM Files (*.htm)
>'HTX Files (*.htx)
>'Database File (*.mdb)
>'Text Files (*.txt)
>'Ascii Files (*.asc)
>'Spreadsheet Files (*.xls)
>'Document Files (*.doc)
>'All Files (*.*)"
>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''
Quote:
> Dim gfni As adh_accOfficeGetFileNameInfo
> With gfni
> .hwndOwner = Application.hWndAccessApp
> .strDlgTitle = strDialogTitle
> .strOpenTitle = strButtonText
> .strFile = ""
> .strInitialDir = strInitDir
> .strFilter = strFilters
> .lngFilterIndex = 1
> .lngView = adhcGfniViewList
> If booDirOnly Then
> .lngFlags = adhcGfniDirectoryOnly
> End If
> End With
> If adhOfficeGetFileName(gfni, booOpen) =
adhcAccErrSuccess Then
Quote:
> fDialog = Trim(gfni.strFile)
> End If
>err_exit:
>Exit Function
>err_handle:
>Call fLogError(err.Number, "fDialog: " & err.Source,
err.description)
>Resume err_exit
>End Function
>Function adhOfficeGetFileName(gfni As
adh_accOfficeGetFileNameInfo, _
Quote:
> ByVal fOpen As Integer) As Long
> ' Use the Office file selector common dialog
> ' exposed by Access.
> Dim lng As Long
> With gfni
> .strAppName = RTrim$(.strAppName) & vbNullChar
> .strDlgTitle = RTrim$(.strDlgTitle) & vbNullChar
> .strOpenTitle = RTrim$(.strOpenTitle) & vbNullChar
> .strFile = RTrim$(.strFile) & vbNullChar
> .strInitialDir = RTrim$(.strInitialDir) &
vbNullChar
> .strFilter = RTrim$(.strFilter) & vbNullChar
> SysCmd acSysCmdClearHelpTopic
> lng = adh_accOfficeGetFileName(gfni, fOpen)
> .strAppName = RTrim$(adhTrimNull(.strAppName))
> .strDlgTitle = RTrim$(adhTrimNull(.strDlgTitle))
> .strOpenTitle = RTrim$(adhTrimNull(.strOpenTitle))
> .strFile = RTrim$(adhTrimNull(.strFile))
> .strInitialDir = RTrim$(adhTrimNull
(.strInitialDir))
> .strFilter = RTrim$(adhTrimNull(.strFilter))
> End With
> adhOfficeGetFileName = lng
>End Function
>Function adhTrimNull(strVal As String) As String
> Dim intPos As Integer
> intPos = InStr(strVal, vbNullChar)
> If intPos > 0 Then
> adhTrimNull = Left$(strVal, intPos - 1)
> Else
> adhTrimNull = strVal
> End If
>End Function
>Hope this helps,
>James
>> Dear all,
>> help on this matter will be greatly appreciated.
>> I want to open an Explorer like window (see attached
file)
>> to retrieve the path of a directory, not of a file.
>> I know that an API exists for Window2000, but I
>> haven't found anything for NT.
>> ------------------------------------------------------
---------------
>> Name: Explorer.bmp
>> Explorer.bmp Type: Bitmap Image (image/bmp)
>> Encoding: base64
>.