L'auteur
FredA France Membre Simple # 0000000005 enregistré le 12/10/2004 Fiche personnelle
Note des membres
pas de note
Contributions > 05 - API et appels systèmes
Récupération des dates d'un fichier (création, modification etc...)
# 0000000234
ajouté le 23/08/2005 15:32:40 et modifié le 23/08/2005
consulté 9182 fois
Niveau
débutant Version(s) Foxpro : VFP 9.0 VFP 8.0 VFP 7.0 VFP 6.0
Description
on utilise l'API comme suit :
# ifdef .F.
BOOL GetFileAttributesEx( LPCTSTR lpFileName, //
file or directory name GET_FILEEX_INFO_LEVELS fInfoLevelId, // attribute class LPVOID lpFileInformation // attribute information };LPCSTR : @ STRING GET_FILEEX_INFO_LEVELS : 0 LPVOID : @ STRING 36 octets
typedef
struct _WIN32_FILE_ATTRIBUTE_DATA{ DWORD dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; DWORD nFileSizeHigh; DWORD nFileSizeLow; } WIN32_FILE_ATTRIBUTE_DATA, *LPWIN32_FILE_ATTRIBUTE_DATA; BOOL FileTimeToSystemTime( CONST FILETIME *lpFileTime, // file time to convert LPSYSTEMTIME lpSystemTime // receives system time );
LPSYSTEMTIME : @
STRING 16 octets LPFILETIME : @ STRING 8 octetstypedef struct _FILETIME { DWORD dwLowDateTime; DWORD dwHighDateTime; } FILETIME, *PFILETIME; typedef struct _SYSTEMTIME { WORD wYear; WORD wMonth; WORD wDayOfWeek; WORD wDay; WORD wHour; WORD wMinute; WORD wSecond; WORD wMilliseconds; } SYSTEMTIME, *PSYSTEMTIME;
#endif
Code source :
DECLARE integer GetFileAttributesEx IN WIN32API string @ cFileName, integer InfoLevel, string @ cFileInfo
DECLARE integer FileTimeToSystemTime IN WIN32API string @ cFileTime, string @ cSystemTime
iInfoLevel=0
cFileInfo=REPLICATE (CHR (0), 36)
cFileName=GETFILE ()
IF EMPTY (cFileName)
RETURN
ENDIF
GetFileAttributesEx(@cFileName, iInfoLevel, @cFileInfo)
cFTCreate = SUBSTR (cFileInfo, 5, 8)
cSTCreate=REPLICATE (CHR (0), 16)
FileTimeToSystemTime(@cFTCreate, @cSTCreate)
iYear = ASC (SUBSTR (cSTCreate, 1, 1))+ 256 * ASC (SUBSTR (cSTCreate, 2, 1))
iMonth = ASC (SUBSTR (cSTCreate, 3, 1))+ 256 * ASC (SUBSTR (cSTCreate, 4, 1))
iDayOfTheWeek = ASC (SUBSTR (cSTCreate, 5, 1))+ 256 * ASC (SUBSTR (cSTCreate, 6, 1))
iDay = ASC (SUBSTR (cSTCreate, 7, 1))+ 256 * ASC (SUBSTR (cSTCreate, 8, 1))
iHour = ASC (SUBSTR (cSTCreate, 9, 1))+ 256 * ASC (SUBSTR (cSTCreate, 10, 1))
iMinute = ASC (SUBSTR (cSTCreate, 11, 1))+ 256 * ASC (SUBSTR (cSTCreate, 12, 1))
iSecond = ASC (SUBSTR (cSTCreate, 13, 1))+ 256 * ASC (SUBSTR (cSTCreate, 14, 1))
iMilliSec = ASC (SUBSTR (cSTCreate, 15, 1))+ 256 * ASC (SUBSTR (cSTCreate, 16, 1))
? iYear, iMonth, iDay
Commentaires
Aucun commentaire enregistré ...