FILEDLG.DLL: description


FILEDLG (FILEDLG.DLL) is a COM module by ERCC that supplies the Windows common dialog for file selection (COMDLG32.DLL) as an object to OLE/COM clients like Visual Basic Script (VBS). It can be used as an alternative to Microsoft's COM module COMDLG32.OCX.
The following excerpt shows the most important VBS instructions.

Set dlg = CreateObject("FileDlg.FileSelection")
dlg.DialogTitle = "Please choose a file"
f = dlg.FileName

FILEDLG is a mere Unicode version for NT-based Windows (from Windows 2000 on). FILEDLG employs the API function GetOpenFileName in a basically similar way as COMDLG32.OCX, but the range of functionality is comparatively modest and targets only the selection of an existing file.

Methods and Properties

All object properties not necessary for the intended use are omitted, that is replaced by internal settings. So the following function parameters and flags are predefined:

Filter = *.*

The string lengths (nMaxFile etc.) are set to 256 characters.

FILEDLG.FileSelection has the following properties that match those of the COMDLG32.OCX module:

DialogTitle sets the dialog box title (IN)
InitDir sets the initial file directory (IN)
FileName returns the path and filename of a selected file (OUT)
FileTitle returns just the name —without the path— of the selected file (OUT)

The function call (method) to show the dialog is named different:

ShowDialog displays an OpenFile common dialog box

FILEDLG.FileSelection has the following additional properties:

FilePath returns just the path of the selected file (OUT)
Error returns an error code (OUT)

The file's path is derived from FileName and the API function's value nFileOffset. A trailing backslash is included.
The error code is determined via API function CommDlgExtendedError if GetOpenFileName returns zero, so this may be the respective DWORD value. Cancelling the file selection does not define an error code.

Folder Selection

Furthermore FILEDLG features the Windows dialog for selecting a folder (Shell API, function SHBrowseForFolder etc.). While this dialog box is available as a COM object by default (SHELL32.DLL), FILEDLG simplifies the use in Visual Basic Script. Besides, there are practical reasons to combine the two selection dialogs.
Simple Example (VBS):

Set dlg = CreateObject("FileDlg.PathSelection")
f = dlg.FolderName

FILEDLG.PathSelection has the following properties:

DialogText sets an additional dialog text, 1024 characters max. (IN)
InitDir sets the initial directory (IN)
FolderName returns the name of a selected folder (OUT)
Error returns an error code (OUT)

This object's purpose is the plain selection of a folder. So the functionality is basically restricted to items (paths) of the file-system. If InitDir is not defined (or in a way not function-compatible), the root object of the file-system is preset, e.g. "My Computer" or the like.
Error may attain one of two error values: 1 indicates that the Shell API function didn't return a result (which is typically the case when the selection was cancelled), 2 would indicate a problem with the internal processing of the directory selection (a theoretical case).

License, Notes

FILEDLG.DLL is provided as freeware and "as is" without any warranty or liability.

Download, Installation

The file contains FILEDLG.DLL along with a descriptive text file.

For installation save FILEDLG.DLL to a directory of your choice and register the file as a COM module (see FILEDLG.TXT for more information).

ERCC (  2011/2016   © Erhard Riedel Computer Consulting (ERCC)

link to info overview