How to Quickly List the Contents of a DirectoryLast reviewed: June 21, 1995Article ID: Q119396 |
The information in this article applies to:
SUMMARYAlthough Visual Basic has both built-in functions (Dir$ and Dir) and a built-in control (File list box) for listing the files in a directory, using a standard list box and the Windows API SendMessage function lists files in a directory much more quickly. NOTE: Replacing the File list box or Dir command using the technique described in this article will only improve performance perceptibly if the File list box or Dir command is used heavily in the application.
MORE INFORMATIONThis technique uses the LB_DIR message for list boxes to add a list of filenames to a list box. To do this, call the Windows API SendMessage function. The SendMessage function requires the following parameters to list the files:
SendMessage (hWnd%, LB_DIR, wParam%, lParam)where
hWnd% is the handle of the list box. wParam% is an integer that specifies the permissible file attributes. lParam is a long pointer to a string containing the full path and file name to add to the list. This can include wildcards.The wParam% argument can be any combination of the following values:
Value Meaning DDL_ARCHIVE File has been archived. DDL_DIRECTORY File must be a directory name. DDL_EXCLUSIVE Exclusive flag. If the exclusive flag is set, only files of the specified type are listed. Otherwise, files of the specified type are listed in addition to files that do not match the specified type. DDL_HIDDEN File must be hidden. DDL_READONLY File must be read only. DDL_READWRITE File can be read from or written to. DDL_SYSTEM File must be a system file. Step-by-Step Example
|
Additional reference words: speed faster 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |