欢 迎 光 临 大海的风's BLog

 ||  

 管理员登陆

 这就是我
  • 日志:363
  • 评论:101
  • 留言:4
  • 访问:

最新公告

本人主要开发过软件有:
<<工厂生产管理系统>>
<<人事管理系统>>
<<货仓管理系统>>
<<发票管理系统>>
<<智能IC卡考勤管理系统>>
<<智能IC卡门禁考勤管理系统>>
<<指文门禁考勤管理系统>>
<<智能巡检管理系统>>
<<酒楼点菜收银系统>>等

站点日历
<<  < 2007 - >  >>
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
最新日志
最新回复
最新留言
 日志搜索

友情链接
Powered By ShineBlog.com
 其他信息
·VB,获取一个文件的建立时间,修改时间     -|fhbmonkey 发表于 2007-6-6 9:23:00

    Dim ObjFileSystem As New FileSystemObject '需引用Microsoft ing Runtime
Dim ObjFile As File
Set ObjFile = ObjFileSystem.GetFile("c:\autoexec.bat") '文件名
Text1.Text = ObjFile.DateCreated '文件创建时间

'Text2.Text = ObjFile.DateLastAccessed '文件访问时间
'Text3.Text = ObjFile.DateLastModified '文件修改时间

 

-----------------------------------------------------------

 

 Const OFS_MAXPATHNAME = 128
  Const OF_READ = &H0
  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 SYSTEMTIME
            wYear   As Integer
            wMonth   As Integer
            wDayOfWeek   As Integer
            wDay   As Integer
            wHour   As Integer
            wMinute   As Integer
            wSecond   As Integer
            wMilliseconds   As Integer
  End Type
   
  Private Type FileTime
            dwLowDateTime   As Long
            dwHighDateTime   As Long
  End Type
   
   
  Private Type BY_HANDLE_FILE_INFORMATION
            dwFileAttributes   As Long
            ftCreationTime   As FileTime
            ftLastAccessTime   As FileTime
            ftLastWriteTime   As FileTime
            dwVolumeSerialNumber   As Long
            nFileSizeHigh   As Long
            nFileSizeLow   As Long
            nNumberOfLinks   As Long
            nFileIndexHigh   As Long
            nFileIndexLow   As Long
  End Type
   
  Private Type TIME_ZONE_INFORMATION
            bias   As Long
            StandardName(32)   As Integer
            StandardDate   As SYSTEMTIME
            StandardBias   As Long
            DaylightName(32)   As Integer
            DaylightDate   As SYSTEMTIME
            DaylightBias   As Long
  End Type
   
   
  Private Declare GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
  Private Declare OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
  Private Declare GetFileInformationByHandle Lib "kernel32" (ByVal hFile As Long, lpFileInformation As BY_HANDLE_FILE_INFORMATION) As Long
  Private Declare CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
  Private Declare FileTimeToSystemTime Lib "kernel32" (lpFileTime As FileTime, lpSystemTime As SYSTEMTIME) As Long
   
   
  Private Sub Form_Load()
    Dim FileHandle     As Long
    Dim FileInfo     As BY_HANDLE_FILE_INFORMATION
    Dim lpReOpenBuff     As OFSTRUCT, ft       As SYSTEMTIME
    Dim tZone     As TIME_ZONE_INFORMATION

    Dim dtCreate     As Date     '   建立时间
    Dim dtAccess     As Date     '   存取日期
    Dim dtWrite     As Date     '   修改时间
    Dim bias     As Long

    '   先取得   autoexec.bat   的   File   Handle
    FileHandle = OpenFile("c:\autoexec.bat", lpReOpenBuff, OF_READ)
    Call GetFileInformationByHandle(FileHandle, FileInfo)
    Call CloseHandle(FileHandle)
    Call GetTimeZoneInformation(tZone)
    bias = tZone.bias       '   时间差,   以「分」为单位

    Call FileTimeToSystemTime(FileInfo.ftCreationTime, ft)       '   转换时间资料结构
    dtCreate = DateSerial(ft.wYear, ft.wMonth, ft.wDay) + TimeSerial(ft.wHour, ft.wMinute - bias, ft.wSecond)
    MsgBox "建立时间" & dtCreate

    Call FileTimeToSystemTime(FileInfo.ftLastAccessTime, ft)
    dtAccess = DateSerial(ft.wYear, ft.wMonth, ft.wDay) + TimeSerial(ft.wHour, ft.wMinute - bias, ft.wSecond)
    MsgBox "修改时间" & dtCreate

    Call FileTimeToSystemTime(FileInfo.ftLastWriteTime, ft)
    dtWrite = DateSerial(ft.wYear, ft.wMonth, ft.wDay) + TimeSerial(ft.wHour, ft.wMinute - bias, ft.wSecond)
    MsgBox "存取时间" & dtCreate
   
  End Sub

[阅读全文 | 回复(0) | 引用通告 | 编辑]

发表评论:

    大名:
    密码: (游客无须输入密码)
    主页:
    标题:
    正在载入数据,请稍候……
Email:fhbmonkey@sohu.com QQ:76111951   大海的风