This sample program shows how to accomplish 3 tasks.
Submitted By:
Unknown
Rating:





(
Rate It)
Attribute VB_Name = "modBrowseForFolder"
' Disclaimer of Warranty:
' This software and the accompanying files are provided "as is"
' and without warranties as to performance of the software and
' the accompanying files or any other warranties whether expressed
' or implied. No warranty of fitness for a particular purpose
' is offered.
'
' You MAY NOT sell this software or it's source code.
' You MAY use this code in any way you find useful.
OPTION Explicit
'Function Declarations, type structure, and constants to use the
'Browse for Folder dialog box. For more information on these,
'consult the SDK, included with VB 4.0 Pro or Ent editions as
'part of the MSDN/VB Starter Kit.
Public DECLARE FUNCTION SHGetPathFromIDList Lib "shell32.dll" _
ALIAS "SHGetPathFromIDListA" (BYVAL pidl AS LONG, _
BYVAL pszPath AS STRING) AS LONG
Public TYPE BROWSEINFO
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
Public DECLARE FUNCTION SHBrowseForFolder Lib "shell32.dll" _
ALIAS "SHBrowseForFolderA" (lpBrowseInfo AS BROWSEINFO) AS LONG
'Below are the constants which can be specified in the ulFlags member
'of the BROWSEINFO structure.
'Only returns file system directories. If the user selects folders
'that are not part of the file system, the OK button is grayed.
Public CONST BIF_RETURNONLYFSDIRS = &H1
'Does not include network folders below the domain level in the
'tree view control.
Public CONST BIF_DONTGOBELOWDOMAIN = &H2
'Only returns file system ancestors. If the user selects anything
'other than a file system ancestor, the OK button is grayed.
Public CONST BIF_RETURNFSANCESTORS = &H8
'Only returns computers. If the user selects anything other than
'a computer, the OK button is grayed.
Public CONST BIF_BROWSEFORCOMPUTER = &H1000
'Only returns printers. If the user selects anything other than
'a printer, the OK button is grayed.
Public CONST BIF_BROWSEFORPRINTER = &H2000
'Includes a status area in the dialog box. The callback function can set the status text by sending messages to the dialog box.
CONST BIF_STATUSTEXT = &H4