hello all,

below in the code section is a MB example of using the WinAPI to "Get
Directory Info"

I'll but together a DLL that can drop a tab delimited file that you specify
or return a string with the info
It will have filename, size, times

In the section "'******** START DOING WHAT YOU NEED HERE"
you can get any of the record data including
FileSize = (nFileSizeHigh * 256) + nFileSizeLow

Expanding the FileDate is a bit tricky
It is built into Delphi but I don't have the "hard code"
It is a "encoded" 64 bit integer in "FileTime Format"


File Attributes hasthe following "Additive" value
  faReadOnly  = $00000001
  faHidden    = $00000002
  faSysFile   = $00000004
  faVolumeID  = $00000008
  faDirectory = $00000010
  faArchive   = $00000020



=============   CODE BEGIN  ======================

'
' WinAPI Demo
'   Find Files
'
'  IN: FileFind (string)
'        full Drive:\Path\Name.Ext of the file to find
'        ex: "c:\*.*" --> finds all files
'        ex: "c:\*.bat" --> returns all files with ext of BAT
'        ex: "c:\MyFile.txt" --> same as FileExists("file")
'        ex: "c:\T?M.txt" --> single char wildcard TIM TOM etc

' OUT: lpFindFileData.cFileName (string) hold last file name [no path]
'      FindMore (integer) returns zero [0] when no more matches
'
'================================================
'========  DATA TYPES USED BY WinAPI  ===========
'========   WARNING: DO NOT MODIFY    ===========
'================================================

'DATA STRUCTURE FOR Win32 TO STORE "FOUND" INFORMATION
DEFINE Max_Path 120
Type WIN32_FIND_DATA
        dwFileAttributes As Integer
        ftCreationTime As Float
        ftLastAccessTime As Float
        ftLastWriteTime As Float
        nFileSizeHigh As Integer
        nFileSizeLow As Integer
        dwReserved0 As Integer
        dwReserved1 As Integer
        cFileName As String * Max_Path
        cAlternate As String * 14
End Type

'===================================================
'==========  API METHODS USED  =====================
'===================================================

'CALLED FIRST [ONLY ONCE] TO BEGIN
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal
lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Integer

'CALLED REPEATEDLY UNTIL THE RETURN IS 0 [zero] ==> FINISHED
Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal
hFindFile As Integer, lpFindFileData As WIN32_FIND_DATA) As Integer



'====================================================
'==========  USER VARIABLE ASSIGNMENTS  =============
'====================================================

'HOLDS THE WinHandle FOR THE LIFE OF THE CALLS
DIM FileHnd as INTEGER

'HOLDS THEN DATA TYPE STRUCTURE FOR WinAPI
DIM lpFindFileData as WIN32_FIND_DATA

'STRING THE USER WISHES TO SEARCH FOR
DIM FileFind as String

'RECURSION VARIABLE TO FOR CALL BACK TO FindNext FUNCTION
dim FindMore as integer

'=====================================================
'========  BEGINNING OF PROCEDURE  ===================
'=====================================================

    'CLEAR THE MESSAGE WINDOW
print chr$(12)

    'SET THE FIRST FILE TO FIND [including drive\path]
    '***** YOU CHANGE THIS VALUE TO WHAT YOU NEED
FileFind="C:\*.*"

    'BEGIN THE "CALL BACK" RECURSION TO FIND ALL OF THE FILES
    'STOPS WHEN FindMore BECOMES ZERO
    '********* ONLY MODIFY INDICATED SECTION FOR YOU NEEDS
FileHnd = FindFirstFile(FileFind,lpFindFileData)
if FileHnd > 0 then
  FindMore=FileHnd
  while FindMore > 0
        '******** START DOING WHAT YOU NEED HERE
    print lpFindFileData.cFileName
        '******** END DOING WHAT YOU NEED
    FindMore=FindNextFile(FileHnd,lpFindFileData)
  wend
else
      'TELL USER THAT THE FIND FAILED
      '****** YOU CAN REMOVE THIS IF YOU DO NOT NEED IT
  note "NO FILES FOUND FOR: "+chr$(10)+""""+FileFind+""""
end if


=============  CODE END  ========================

Trey Pattillo
[EMAIL PROTECTED]
www.wap3.com
-97.665333W 27.799121N


----- Original Message -----
From: "Tom Thomson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 22 October, 2002 20:09
Subject: MI-L Export file info from Win Explorer


> I was wondering if it is possible to get file name, size, date and time
> info, etc out of Win Explorer window to insert into a spreadsheet?
>
> I tried cut n paste....no go
> I tried print to file...no go
> I tried the net for some keen utility....so far no go
>
> Any ideas???  Thanks in advance...tom
>
> ====================================================
> Tom Thomson                          Northwest Agricultural Consulting
> 1275 Oak Villa Road                                  [EMAIL PROTECTED]
> Dallas, Oregon 97338                            Phone/FAX 503-623-0468
>
> "The only difference between a problem and a solution is that
> everyone understands the solution." Charles Kettering
> ====================================================
>
>
> ---------------------------------------------------------------------
> List hosting provided by Directions Magazine | www.directionsmag.com |
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> Message number: 3716
>


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 3741

Reply via email to