如题
解决方案 »
- VB6.0中的Textbox控件在哪里?没找着!
- 请问vb是否可以同时连接两个.mdb文件
- 高手 帮帮忙吧 我要疯了--------------------------------------------------------------------------------------------------------------------
- 论坛消息模块有问题呀!散分帖(每天发帖可得30分了)
- 如何使用VB获得网站的股票报价
- 调查一下:请问你的工作环境是怎样的?
- 如何修改文件的属性,----把只读,存储,隐藏属性去掉
- 怎样控制两个紧贴在一起的picturebox,通过鼠标在中间拉动,左右两picturebox也自动调节width,保持紧贴在一起?
- VB中什么控件可以让用户输入密码?
- help me !!!vb6.0 項目 轉換為 vb.net 之後出現的問題 關於 sheet元素的顯示
- 关于mapX
- 晕!!什么方法都试过了,就是引用不了COM+!!
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Declare Function GetFileTime Lib "kernel32" Alias "GetFileTime" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
说明
取得指定文件的时间信息
返回值
Long,非零表示成功,零表示失败。会设置GetLastError
参数表
参数 类型及说明
hFile Long,文件的句柄
lpCreationTime FILETIME,用于装载文件的创建时间
lpLastAccessTime FILETIME,用于装载文件上一次访问的时间(FAT文件系统不支持这一特性)
lpLastWriteTime FILETIME,用于装载文件上一次修改的时间
注解
如果不需要特定的信息,那么lpCreationTime,lpLastAccessTime,lpLastWriteTime都可以设置为零(用ByVal As Long)。这个函数返回的文件时间采用UTC格式
Type FILETIME ' 8 Bytes
dwLowDateTime As Long
dwHighDateTime As Long
End Type
说明
windows提供了一种特殊的机制,可以记录文件的访问及创建时间。在win32环境中,这些信息以64位值的形式保存,量度的是自1601年1月1日以来经历的100ns时间单位数量(64-bit number specifying the elapsed time since January 1, 1601, in 100-nanosecond increments.)
字段表
字段 类型及说明
dwLowDateTime Long,Low and high-order 32 bits of the file time
dwHighDateTime
注解
文件时间在系统中通常用“协同世界时间”(UTC)的格式保存,但同时提供了在UTC及本地时间之间转换的函数。FILETIME结构里可包含UTC或本地时间——由我们自行决定在结构中包含什么时间
楼主是要获得最后一次修改的时间。
你给了我两个API函数,我不知道应该怎么调用它们,能不能给我一个调用它的代码呀,谢谢!
Private Declare Function GetFileTime Lib "kernel32" (ByVal hFile As Long, lpCreationTime As FILETIME, lpLastAccessTime As FILETIME, lpLastWriteTime As FILETIME) As Long
Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
Private Const OF_CANCEL = &H800
Private Const OF_CREATE = &H1000
Private Const OF_DELETE = &H200
Private Const OF_EXIST = &H4000
Private Const OF_PARSE = &H100
Private Const OF_PROMPT = &H2000
Private Const OF_READ = &H0
Private Const OF_READWRITE = &H2
Private Const OF_REOPEN = &H8000
Private Const OF_SHARE_COMPAT = &H0
Private Const OF_SHARE_DENY_NONE = &H40
Private Const OF_SHARE_DENY_READ = &H30
Private Const OF_SHARE_DENY_WRITE = &H20
Private Const OF_SHARE_EXCLUSIVE = &H10
Private Const OF_VERIFY = &H400
Private Const OF_WRITE = &H1
Private Const OFS_MAXPATHNAME = 128
Private Type OFSTRUCT
cBytes As Byte
fFixedDisk As Byte
nErrCode As Integer
Reserved1 As Integer
Reserved2 As Integer
szPathName(OFS_MAXPATHNAME) As Byte
End Type
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End TypePrivate Sub Command1_Click()
Dim fStruct As OFSTRUCT
Dim CreationTime As FILETIME
Dim LastAccessTime As FILETIME
Dim LastWriteTime As FILETIME
Dim hFile As Long
With fStruct
.cBytes = 136
End With
hFile = OpenFile("c:\123.txt", fStruct, OF_READ)
GetFileTime hFile, CreationTime, LastAccessTime, LastWriteTime
Debug.Print CreationTime.dwHighDateTime
Debug.Print CreationTime.dwLowDateTime
End Sub但dwHighDateTime和dwLowDateTime不是我们一眼能看懂的,得转换。MSDN是这样说的:FILETIME
The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601. typedef struct _FILETIME { // ft
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;
Members
dwLowDateTime
Specifies the low-order 32 bits of the file time.
dwHighDateTime
Specifies the high-order 32 bits of the file time.
Res
It is not recommended that you add and subtract values from the FILETIME structure to obtain relative times. Instead, you should Copy the resulting FILETIME structure to a LARGE_INTEGER structure.
Use normal 64-bit arithmetic on the LARGE_INTEGER value.
Debug.Print FileDateTime("c:\123.txt")
End Sub
返回一个 Variant (Date),此为一个文件被创建或最后修改后的日期和时间。语法FileDateTime(pathname)必要的 pathname 参数是用来指定一个文件名的字符串表达式。pathname 可以包含目录或文件夹、以及驱动器。
FSO.GetFile("文件名").DateLastModified,即可返回上次修改日期。
两位大侠,能不能留下联系方式呀,谢谢
本人无QQ,勿见怪