Shell32.dll
Thanks for visiting my site lucky visitor:
This page was last updated on: March 15, 2008
Copyright © 2002. XcelFiles. All Rights Reserved Ivan F Moala
Tell a friend about this page
Google
Search WWW Search My Site!

Browse for Folder:

In the Page Shell32 Example here I gave an example of it's use to browse for a folder and get info on various files within the Folder. This is the 1st part of the wider Shell32.dll. In May 2002 I looked @ this function and realised its' potential, having looked @ microsoft specs for this.
Then after this post in April 2003, I left it alone. Now @ long last I have decided to place it on my site. Below is the code you can use to browse for a folder.

Requires DLL version shell32.dll version 4.71 or later
Operating systems
Win2000, WinNT 4.0 with Internet Explorer 4.0, Win98, Win95 with Internet Explorer 4.0

Item Identifiers and Identifier Lists
The Shell uses object identifiers within the Shell's namespace. All objects visible in the Shell (files, directories, servers, workgroups, and so on) have unique identifiers among the objects within their parent folder. These identifiers are called item identifiers, and they have the SHITEMID data type as defined in the Shtypes.h header file. An item identifier is a variable-length byte stream that contains information that identifies an object within a folder. Only the creator of an item identifier knows the content and format of the identifier. The only part of an item identifier that the Shell uses is the first two bytes, which specify the size of the identifier.
For the API declaration the SHITEMID structure looks like this;

Type SHITEMID   'mkid
   cb As Long      'Size of the ID (including cb itself)
   abID As Byte   'The item ID (variable length)
End Type

Each parent folder has its own item identifier that identifies it within its own parent folder.
Thus, any Shell object can be uniquely identified by a list of item identifiers. A parent folder keeps a list of identifiers for the items it contains. The list has the ITEMIDLIST data type. Item identifier lists are allocated by the Shell and may be passed across Shell interfaces, such as IShellFolder. It is important to remember that each identifier in an item identifier list is only meaningful within the context of its parent folder.

Type ITEMIDLIST  'idl
   mkid As SHITEMID
End Type

An application can set a shortcut's item identifier list by using the SetIDList method. This method is useful when setting a shortcut to an object that is not a file, such as a printer or disk drive. An application can retrieve a shortcut's item identifier list by using the GetIDList method.

What is a PIDL? Why not just use file system paths?
A PIDL (Program ID list) is a way of identifying any namespace object. You can also use paths to identify namespace objects, but only if they are part of the file system. With namespace objects that are not part of the file system, you must use PIDLs.

BIF_Options Discriptions here
Public Const BIF_BROWSEFORCOMPUTER = &H1000
Public Const BIF_BROWSEFORPRINTER = &H2000
Public Const BIF_BROWSEINCLUDEFILES = &H4000
Public Const BIF_BROWSEINCLUDEURLS = &H80
Public Const BIF_DONTGOBELOWDOMAIN = &H2
Public Const BIF_EDITBOX = &H10
Public Const BIF_NEWDIALOGSTYLE = &H40
Public Const BIF_RETURNFSANCESTORS = &H8
Public Const BIF_RETURNONLYFSDIRS = &H1
Public Const BIF_SHAREABLE = &H8000
Public Const BIF_STATUSTEXT = &H4
Public Const BIF_USENEWUI = &H40
Public Const BIF_VALIDATE = &H20
Public Const BIF_NONEWFOLDERBUTTON = &H200

CSIDL values provide a unique system-independent way to identify special folders
used frequently by applications, but which may not have the same name or location
on any given system. For example, the system folder may be
"C:\Windows\System" on one system and "C:\Winnt\System32" on another, typically Work :-)

Tip:
Enum the CSIDL constants for easier data changing.
Make sure Auto List Member is Ticked — Displays a list that contains information that would logically complete the statement at the current insertion point.
eg Typing in SpecFolders gives you all the Constants below

Here is The List I was able to gather = 53
Some of which may NOT be avail for your OS
Make it Public so it is avail to All your Modules

Public Enum SpecFolders
   CSIDL_APPDATA = &H1A
   CSIDL_BITBUCKET = &HA
   CSIDL_COMMON_DESKTOPDIRECTORY = &H19
   CSIDL_COMMON_DOCUMENTS = &H2E
   CSIDL_COMMON_FAVORITES = &H1F
   CSIDL_COMMON_PROGRAMS = &H17
   CSIDL_COMMON_STARTMENU = &H16
   CSIDL_COMMON_STARTUP = &H18
   CSIDL_COMMON_TEMPLATES = &H2D
   CSIDL_COMMONALTSTARTUP = &H1E
   CSIDL_COMMONAPPDATA = &H23
   CSIDL_COMMONDESKTOP = &H0
   CSIDL_COMMONMYMUSIC = &H35
   CSIDL_COMMONMYPICTURES = &H36
   CSIDL_COMMONMYVIDEOS = &H37
   CSIDL_COMMONSTARTADMIN = &H2F
   CSIDL_CONNECTIONS = &H31
   CSIDL_CONTROLS = &H3
   CSIDL_DRIVES = &H11
   CSIDL_FAVORITES = &H6
   CSIDL_FONTS = &H14
   CSIDL_LOCALALTSTARTUP = &H1D
   CSIDL_LOCALAPPDATA = &H1C
   CSIDL_LOCALAPPMSCDBURNING = &H3B
   CSIDL_LOCALCOOKIES = &H21
   CSIDL_LOCALDESKTOPDIRECTORY = &H10
   CSIDL_LOCALHISTORY = &H22
   CSIDL_LOCALINTERNETCACHE = &H20
   CSIDL_LOCALMYVIDEOS = &HE
   CSIDL_LOCALSTARTADMIN = &H30
   CSIDL_MSHOME = &H3D
   CSIDL_MYMUSIC = &HD
   CSIDL_MYPICTURES = &H27
   CSIDL_NETHOOD = &H13
   CSIDL_NETWORK = &H12
   CSIDL_PERSONAL = &H5
   CSIDL_PRINTERS = &H4
   CSIDL_PRINTHOOD = &H1B
   CSIDL_PROFILE = &H28
   CSIDL_PROGRAM_FILES = &H26
   CSIDL_PROGRAM_FILES_COMMON = &H2B
   CSIDL_PROGRAM_FILES_COMMONX86 = &H2C
   CSIDL_PROGRAM_FILESX86 = &H2A
   CSIDL_PROGRAMS = &H2
   CSIDL_RECENT = &H8
   CSIDL_RESOURCES = &H39
   CSIDL_SENDTO = &H9
   CSIDL_STARTMENU = &HB
   CSIDL_STARTUP = &H7
   CSIDL_SYSTEM = &H25
   CSIDL_SYSTEMX86 = &H29
   CSIDL_TEMPLATES = &H15
   CSIDL_WINDOWS = &H24
End Enum
  
Private Const BIF_BROWSEFORCOMPUTER = &H1000Only return computers. If the user selects anything other than a computer, the OK button is grayed.
Private Const BIF_BROWSEFORPRINTER = &H2000Only allow the selection of printers. If the user selects anything other than a printer, the OK button is grayed.In Microsoft® Windows® XP, the best practice is to use an XP-style dialog, setting the root of the dialog to the Printers and Faxes folder (CSIDL_PRINTERS).
Private Const BIF_BROWSEINCLUDEFILES = &H4000Version 4.71. The browse dialog box will display files as well as folders.
Private Const BIF_BROWSEINCLUDEURLS = &H80Version 5.0. The browse dialog box can display URLs. The BIF_USENEWUI and BIF_BROWSEINCLUDEFILES flags must also be set. If these three flags are not set, the browser dialog box will reject URLs. Even when these flags are set, the browse dialog box will only display URLs if the folder that contains the selected item supports them. When the folder's IShellFolder::GetAttributesOf method is called to request the selected item's attributes, the folder must set the SFGAO_FOLDER attribute flag. Otherwise, the browse dialog box will not display the URL.
Private Const BIF_DONTGOBELOWDOMAIN = &H2Do not include network folders below the domain level in the dialog box's tree view control.
Private Const BIF_EDITBOX = &H10Version 4.71. Include an edit control in the browse dialog box that allows the user to type the name of an item.
Private Const BIF_NEWDIALOGSTYLE = &H40Version 5.0. Use the new user interface. Setting this flag provides the user with a larger dialog box that can be resized. The dialog box has several new capabilities including: drag and drop capability within the dialog box, reordering, shortcut menus, new folders, delete, and other shortcut menu commands. To use this flag, you must call OleInitialize or CoInitialize before calling SHBrowseForFolder.
Private Const BIF_RETURNFSANCESTORS = &H8Only return file system ancestors. An ancestor is a subfolder that is beneath the root folder in the namespace hierarchy. If the user selects an ancestor of the root folder that is not part of the file system, the OK button is grayed.
Private Const BIF_RETURNONLYFSDIRS = &H1Only return file system directories. If the user selects folders that are not part of the file system, the OK button is grayed.
Private Const BIF_SHAREABLE = &H8000Version 5.0. The browse dialog box can display shareable resources on remote systems. It is intended for applications that want to expose remote shares on a local system. The BIF_NEWDIALOGSTYLE flag must also be set.
Private Const BIF_STATUSTEXT = &H4Include a status area in the dialog box. The callback function can set the status text by sending messages to the dialog box. This flag is not supported when BIF_NEWDIALOGSTYLE is specified.
Private Const BIF_USENEWUI = &H40Version 5.0. Use the new user interface, including an edit box. This flag is equivalent to BIF_EDITBOX | BIF_NEWDIALOGSTYLE. To use BIF_USENEWUI, you must call OleInitialize or CoInitialize before calling SHBrowseForFolder.
Private Const BIF_VALIDATE = &H20Version 4.71. If the user types an invalid name into the edit box, the browse dialog box will call the application's BrowseCallbackProc with the BFFM_VALIDATEFAILED message. This flag is ignored if BIF_EDITBOX is not specified.
BIF Constant discriptions
Can Do
Know thy self
Know thy self
Know thy self
What kind of ink does your printer take? Can't find Magicolor toner cartridges or ink cartridges at your local office supply store? Just look online! You can get wholesale Oki toner cartridges at great prices, and cheap Samsung toner cartridges are easier than ever to find.