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
发表于 @ 2008年01月17日 18:11:00 | 评论( loading... ) | 举报| 收藏