// use WinFolder.nui // WinFolder_ReadFolder message Use Base.nui // Item_Property command, Various macros (FOR_EX...), cArray, cSet and cStack classes (No User Interface) Use Files.nui // Utilities for handling file related stuff (No User Interface) Use Dates.nui // Date routines (No User Interface) Use vWin32fh.pkg // Win API functions by Wil van Antwerpen of VDF-GuiDance #IFDEF FILE_ATTRIBUTE_DIRECTORY #ELSE Define FILE_ATTRIBUTE_READONLY for |CI$00000001 Define FILE_ATTRIBUTE_HIDDEN for |CI$00000002 Define FILE_ATTRIBUTE_SYSTEM for |CI$00000004 Define FILE_ATTRIBUTE_DIRECTORY for |CI$00000010 Define FILE_ATTRIBUTE_ARCHIVE for |CI$00000020 Define FILE_ATTRIBUTE_ENCRYPTED for |CI$00000040 Define FILE_ATTRIBUTE_NORMAL for |CI$00000080 Define FILE_ATTRIBUTE_TEMPORARY for |CI$00000100 Define FILE_ATTRIBUTE_SPARSEFILE for |CI$00000200 Define FILE_ATTRIBUTE_REPARSEPOINT for |CI$00000400 Define FILE_ATTRIBUTE_COMPRESSED for |CI$00000800 Define FILE_ATTRIBUTE_OFFLINE for |CI$00001000 #ENDIF desktop_section object oWinFolderEntries is a cArray property integer piFileCount property integer piFolderCount property string psFolder item_property_list item_property integer pbFolder.i item_property string psFileName.i item_property string psAlternateFileName.i item_property number pnFileSz.i item_property number pnCreated.i item_property number pnLastWrite.i item_property number pnLastAccessed.i item_property integer piAttributes.i end_item_property_list function nFileTimeTS dword ldwHi dword ldwLo returns number Integer iSuccess Date dDate Number nRval tvFileTime stFileTime tvSystemTime stSystemTime Move ldwHi to stFileTime.dwHighDateTime Move ldwLo to stFileTime.dwLowDateTime Move (vWin32_FileTimeToSystemTime(AddressOf(stFileTime), AddressOf(stSystemTime))) to iSuccess If (iSuccess=1) Begin Get DateCompose stSystemTime.wDay stSystemTime.wMonth stSystemTime.wYear to dDate Get TS_Compose2 dDate stSystemTime.wHour stSystemTime.wMinute stSystemTime.wSecond to nRval Function_Return nRval end function_return 0 end_function Procedure DoLoad String sFolderPath Handle hFindFile Integer iVoid iRow iFileCount iFolderCount Boolean bRetval bFolder bFound Number nTS String sFileName tvWin32FindData stFindData Move 0 to iFileCount Move 0 to iFolderCount Set psFolder to sFolderPath Send delete_data If (not(Pos("*",sFolderPath) or Pos("?",sFolderPath))) Begin Get Files_AppendPath sFolderPath "*" to sFolderPath End Move (ToAnsi(sFolderPath)) to sFolderPath Move 0 to stFindData.dwReserved0 // initialize the variable so we can get an address from it Move (vWin32_FindFirstFile(AddressOf(sFolderPath), AddressOf(stFindData))) to hFindFile Move (hFindFile<>vINVALID_HANDLE_VALUE) to bFound While (bFound) Move (UCharArrayToString(stFindData.cFileName)) to sFileName If (sFileName="." or sFileName="..") Begin Get row_count to iRow Set psFileName.i iRow to (ToOEM(sFileName)) Set piAttributes.i iRow to stFindData.dwFileAttributes Move (stFindData.dwFileAttributes iand FILE_ATTRIBUTE_DIRECTORY) to bFolder Set pbFolder.i iRow to bFolder If (bFolder) Begin Increment iFolderCount End Else Begin Increment iFileCount End Set psAlternateFileName.i iRow to (UCharArrayToString(stFindData.cAlternateFileName)) Set pnFileSz.i iRow to (stFindData.nFileSizeHigh*4294967296+stFindData.nFileSizeLow) // (ldwHi*4294967296+ldwLo) Get nFileTimeTS stFindData.ftCreationHighDateTime stFindData.ftCreationLowDateTime to nTS Set pnCreated.i iRow to nTS Get nFileTimeTS stFindData.ftLastWriteHighDateTime stFindData.ftLastWriteLowDateTime to nTS Set pnLastWrite.i iRow to nTS Get nFileTimeTS stFindData.ftLastAccessHighDateTime stFindData.ftLastAccessLowDateTime to nTS Set pnLastAccessed.i iRow to nTS End Move (vWin32_FindNextFile(hFindFile, AddressOf(stFindData))) to hFindFile Move (hFindFile<>0) to bFound Loop Move (vWin32_FindClose(hFindFile)) to iVoid Set piFileCount to iFileCount Set piFolderCount to iFolderCount End_Procedure // Procedure DoLoadOld String lsFolderPath // Handle lhImportFile // Pointer lpsPath lps32Data // DWord ldwFileAtt ldwHi ldwLo // Integer liVoid liRow liFileCount liFolderCount // Boolean lbRetval lbFolder // Number lnTS // String lsWin32FindData lsFileName // // Move 0 to liFileCount // Move 0 to liFolderCount // Set psFolder to lsFolderPath // // Send delete_data // // ifnot (pos("*",lsFolderPath) or pos("?",lsFolderPath)) Begin // Get Files_AppendPath lsFolderPath "*" to lsFolderPath // End // // Move (ToAnsi(lsFolderPath)) to lsFolderPath // // GetAddress of lsFolderPath to lpsPath // ZeroType vWin32_Find_Data to lsWin32FindData // GetAddress of lsWin32FindData to lps32Data // Move (vWin32_FindFirstFile(lpsPath,lps32Data)) to lhImportFile // If (lhImportFile <> INVALID_HANDLE_VALUE) Begin // Repeat // Get row_count to liRow // // GetBuff_String from lsWin32FindData at vWin32_Find_Data.cFileName to lsFileName // // If (lsFileName<>"." and lsFileName<>"..") Begin // Set psFileName.i liRow to (ToOem(lsFileName)) // // GetBuff from lsWin32FindData at vWin32_Find_Data.dwFileAttributes to ldwFileAtt // Set piAttributes.i liRow to ldwFileAtt // // Move (ldwFileAtt iand FILE_ATTRIBUTE_DIRECTORY) to lbFolder // Set pbFolder.i liRow to lbFolder // // If lbFolder Increment liFolderCount // Else Increment liFileCount // // GetBuff_String from lsWin32FindData at vWin32_Find_Data.cAlternateFileName to lsFileName // get attribute // Set psAlternateFileName.i liRow to lsFileName // // GetBuff from lsWin32FindData at vWin32_Find_Data.nFileSizeHigh to ldwHi // GetBuff from lsWin32FindData at vWin32_Find_Data.nFileSizeLow to ldwLo // Set pnFileSz.i liRow to (ldwHi*4294967296+ldwLo) // // GetBuff from lsWin32FindData at vWin32_Find_Data.ftCreationHighDateTime to ldwHi // GetBuff from lsWin32FindData at vWin32_Find_Data.ftCreationLowDateTime to ldwLo // Get nFileTimeTS ldwHi ldwLo to lnTS // Set pnCreated.i liRow to lnTS // // GetBuff from lsWin32FindData at vWin32_Find_Data.ftLastWriteHighDateTime to ldwHi // GetBuff from lsWin32FindData at vWin32_Find_Data.ftLastWriteLowDateTime to ldwLo // Get nFileTimeTS ldwHi ldwLo to lnTS // Set pnLastWrite.i liRow to lnTS // // GetBuff from lsWin32FindData at vWin32_Find_Data.ftLastAccessHighDateTime to ldwHi // GetBuff from lsWin32FindData at vWin32_Find_Data.ftLastAccessLowDateTime to ldwLo // Get nFileTimeTS ldwHi ldwLo to lnTS // Set pnLastAccessed.i liRow to lnTS // End // Move (vWin32_FindNextFile(lhImportFile,lps32Data)) to lbRetval // get next file in directory // Until (lbRetval = False) // Move (vWin32_FindClose(lhImportFile)) to liVoid // // End // Set piFileCount to liFileCount // Set piFolderCount to liFolderCount // End_Procedure End_Object // oWinFolderEntries end_desktop_section procedure WinFolder_ReadFolder global string lsFolder send DoLoad of oWinFolderEntries lsFolder end_procedure