http://blog.csdn.net/eastlife2008/article/details/2049983
PB文法:
結構體定義:
global type win32_find_data from structure
unsignedlong dwFileAttributes
unsignedlong ftCreationTime
unsignedlong ftLastAccessTime
unsignedlong ftLastWriteTime
unsignedlong nFileSizeHigh
unsignedlong nFileSizeLow
unsignedlong dwReserved0
unsignedlong dwReserved1
character cFileName[260]
character cAlternateFileName[14]
end type
global type ofstruct from structure
unsignedinteger cbytes
unsignedinteger ffixeddisk
integer nerrcode
integer reserved1
integer reserved2
character szpathname[128]
end type
global type filetime from structure
long dwLowDateTime
long dwHighDateTime
end type
global type systemtime from structure
Integer wYear
Integer wMonth
Integer wDayOfWeek
Integer wDay
Integer wHour
Integer wMinute
Integer wSecond
Integer wMilliseconds
end type
函數定義如下:
//尋找檔案的日期時間
FUNCTION ulong CloseHandle(ulong hObject) LIBRARY "kernel32.dll" Alias for "CloseHandle;ansi"
FUNCTION ulong OpenFile(ref string lpFileName,ref OFSTRUCT lpReOpenBuff,ulong wStyle) LIBRARY "kernel32.dll" Alias for "OpenFile;ansi"
FUNCTION ulong FileTimeToSystemTime(ref FILETIME lpFileTime,ref SYSTEMTIME lpSystemTime) LIBRARY "kernel32.dll" Alias for "FileTimeToSystemTime;ansi"
FUNCTION ulong GetFileTime(ulong hFile,ref FILETIME lpCreationTime,ref FILETIME lpLastAccessTime,ref FILETIME lpLastWriteTime) LIBRARY "kernel32.dll" Alias for "GetFileTime;ansi"
//尋找檔案
Function Long FindFirstFile(String lpFileName, ref WIN32_FIND_DATA lpFindFileData) Library "kernel32" Alias for "FindFirstFileA;ansi"
Function Long FindNextFile(Long hFindFile, ref WIN32_FIND_DATA lpFindFileData) Library "kernel32" Alias for "FindNextFileA;ansi"
Function Long FindClose(Long hFindFile) Library "kernel32" Alias for "FindClose;ansi"
Function Long GetLastError() Library "kernel32" Alias for "GetLastError;ansi"
代碼部分(尋找檔案):
win32_find_data findata
ofstruct lst_ofstruct
filetime lst_filetime1,lst_filetime2,lst_filetime3
SYSTEMTIME SYS1
ll_ret = FindFirstFile(ls_Drieve,findata)
if ll_ret <> -1 then
b_hadfile = true
//得出檔案大小
ll_filesize = FileLength(ls_findFN)
//得出檔案的修改時間
lul_hFile=openfile(ls_findFN,lst_ofstruct,0)
GetFileTime(lul_hFile,lst_filetime1,lst_filetime2,lst_filetime3)
FileTimeToSystemTime(LST_FileTime3,SYS1)
CloseHandle(lul_hfile)
dt_fileEditdt = datetime(string(SYS1.wYear) + "-" + string(SYS1.wMonth) + "-" + string(SYS1.wDay) + &
" " + string(SYS1.wHour) + ":" + string(SYS1.wMinute) + ":" + string(SYS1.wSecond))
dt_fileEditdt = Datetime(date(dt_fileEditdt),Time(RelativeTime(Time(dt_fileEditdt),28800)))
do while FindNextFile(ll_ret,findata) <> 0
//得出檔案大小
ll_filesize = FileLength(ls_findFN)
//得出檔案的修改時間
lul_hFile=openfile(ls_findFN,lst_ofstruct,0)
GetFileTime(lul_hFile,lst_filetime1,lst_filetime2,lst_filetime3)
FileTimeToSystemTime(LST_FileTime3,SYS1)
CloseHandle(lul_hfile)
dt_fileEditdt = datetime(string(SYS1.wYear) + "-" + string(SYS1.wMonth) + "-" + string(SYS1.wDay) + &
" " + string(SYS1.wHour) + ":" + string(SYS1.wMinute) + ":" + string(SYS1.wSecond))
dt_fileEditdt = Datetime(date(dt_fileEditdt),Time(RelativeTime(Time(dt_fileEditdt),28800)))
loop
//關閉尋找檔案
FindClose(ll_ret)
else
b_hadfile = false
end if