Hale, Jim
Jim.Hale at FleetPride.com
Wed Feb 9 09:07:08 CST 2005
I can't get it to compile. It doesn't like SHGetPathFromIDList. Am I missing
a reference? TIA
Jim Hale
-----Original Message-----
From: Stuart McLachlan [mailto:stuart at lexacorp.com.pg]
Sent: Tuesday, February 08, 2005 10:21 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Selecting a directory
On 8 Feb 2005 at 22:36, John W. Colby wrote:
> I have used the ADH FindFile module and function for ages. However I also
> need to select a directory (to copy a file to for example) and the ADH
code
> only allows selecting a file, not a dir. Is there any way to cause that
> code to select a directory? Is there another module / function to use the
> fileFind dialog to select a directory?
>
Here's the necessary bits to use the SHBrowseForFolder API call:
Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Public Type BROWSEINFO 'BI
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
'BROWSEINFO.ulFlags values:
Public Const BIF_RETURNONLYFSDIRS = &H1 'Only file system directories
Public Const BIF_DONTGOBELOWDOMAIN = &H2 'No network folders below
domain level
Public Const BIF_STATUSTEXT = &H4 'Includes status area in the
dialog (for callback)
Public Const BIF_RETURNFSANCESTORS = &H8 'Only returns file system
ancestors
Public Const BIF_EDITBOX = &H10 'Allows user to rename
selection
Public Const BIF_VALIDATE = &H20 'Insist on valid editbox
result (or CANCEL)
Public Const BIF_BROWSEFORCOMPUTER = &H1000 'Only returns computers.
Public Const BIF_BROWSEFORPRINTER = &H2000 'Only returns printers.
Public Const BIF_BROWSEINCLUDEFILES = &H4000 'Browse for everything
Public Const MAX_PATH = 260
Private Sub btnBrowseForFolder_Click()
Dim pidl As Long
Dim BI As BROWSEINFO
Dim sPath As String
Dim pos As Integer
'Fill BROWSEINFO structure data
With BI
.hOwner = 0
.pidlRoot = 0
.lpszTitle = "Browsing"
.ulFlags = 1
.pszDisplayName = Space$(260)
End With
'show dialog returning pidl to selected item
pidl = SHBrowseForFolder(BI)
'if pidl is valid, parse & return the user's selection
sPath = Space$(260)
If SHGetPathFromIDList(ByVal pidl, ByVal sPath) Then
'SHGetPathFromIDList returns the absolute
'path to the selected item. No path is returned for virtual folders.
pos = InStr(sPath, Chr$(0))
If pos Then Text1 = Left(sPath, pos - 1)
Else:
Text1 = "Problem"
End If
'free the pidl
Call CoTaskMemFree(pidl)
End Sub
--
Stuart
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.