|
Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal
wMsg%, ByVal wParam%, lParam As Any) ' Note**, The author defined these constants, so you ' won't find them in API documentation, although they ' are based on values used with LB_DIR. Global Const WM_USER = &H400 Global Const LB_DIR = (WM_USER + 14) Global Const DIR_NORMALFILES = &H0 Global Const DIR_READONLY = &H8001 Global Const DIR_HIDDEN = &H8002 Global Const DIR_SYSTEM = &H8004 Global Const DIR_DIRECTORIES = &H8010 Global Const DIR_ARCHIVED = &H8020 Global Const DIR_DRIVES = &HC000 ' Add this routine to your Form's declaration section: Sub ListFiles (sFileSpec As String) Dim i As Long ' Clear existing data List1.Clear ' Add files / directories of specified types i = SendMessage(List1.hWnd, LB_DIR, DIR_DRIVES, ByVal sFileSpec) i = SendMessage(List1.hWnd, LB_DIR, DIR_DIRECTORIES, ByVal sFileSpec) i = SendMessage(List1.hWnd, LB_DIR, DIR_NORMALFILES, ByVal sFileSpec) End Sub ' In Command1_Click call the ListFiles routine: Sub Command1_Click () ' List all files from C:\Windows directory Call ListFiles("C:\WINDOWS\*.*") ' Or to list the whole tree for the current drive: ' Call ListFiles("*.*") End Sub |