⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmain.frm

📁 主要是一些文件操作的技巧
💻 FRM
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmMain 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "File Info Demo Project"
   ClientHeight    =   4470
   ClientLeft      =   3105
   ClientTop       =   3330
   ClientWidth     =   5670
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4470
   ScaleWidth      =   5670
   Begin MSComDlg.CommonDialog dialog 
      Left            =   4680
      Top             =   2760
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      CancelError     =   -1  'True
      DialogTitle     =   "File Info Demo Project"
      Filter          =   "All Files (*.*) | *.*"
      Flags           =   2101252
   End
   Begin VB.TextBox txtsize 
      Height          =   375
      Left            =   960
      Locked          =   -1  'True
      TabIndex        =   19
      Top             =   840
      Width           =   4455
   End
   Begin VB.TextBox txtname 
      Height          =   375
      Left            =   960
      Locked          =   -1  'True
      TabIndex        =   18
      Top             =   240
      Width           =   4455
   End
   Begin VB.Frame fradates 
      Caption         =   "参数"
      Height          =   2175
      Left            =   2040
      TabIndex        =   9
      Top             =   1320
      Width           =   3375
      Begin VB.Label lbldate 
         Caption         =   "00/00/0000 00:00:00"
         Height          =   375
         Index           =   0
         Left            =   1560
         TabIndex        =   15
         Top             =   240
         Width           =   1695
      End
      Begin VB.Label lbldatetxt 
         Caption         =   "创建时间:"
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   14
         Top             =   360
         Width           =   1215
      End
      Begin VB.Label lbldatetxt 
         Caption         =   "最后一次修改时间:"
         Height          =   375
         Index           =   1
         Left            =   240
         TabIndex        =   13
         Top             =   840
         Width           =   855
      End
      Begin VB.Label lbldate 
         Caption         =   "00/00/0000 00:00:00"
         Height          =   375
         Index           =   1
         Left            =   1560
         TabIndex        =   12
         Top             =   840
         Width           =   1695
      End
      Begin VB.Label lbldatetxt 
         Caption         =   "最后一次访问时间:"
         Height          =   495
         Index           =   2
         Left            =   240
         TabIndex        =   11
         Top             =   1440
         Width           =   975
      End
      Begin VB.Label lbldate 
         Caption         =   "00/00/0000 00:00:00"
         Height          =   495
         Index           =   2
         Left            =   1560
         TabIndex        =   10
         Top             =   1440
         Width           =   1695
      End
   End
   Begin VB.CommandButton ok 
      Cancel          =   -1  'True
      Caption         =   "退出"
      Default         =   -1  'True
      Height          =   495
      Left            =   240
      TabIndex        =   8
      Top             =   3720
      Width           =   5175
   End
   Begin VB.Frame fraattrib 
      Caption         =   "属性"
      Height          =   2175
      Left            =   240
      TabIndex        =   0
      Top             =   1320
      Width           =   1695
      Begin VB.CheckBox attributes 
         Caption         =   "一般"
         Height          =   195
         Index           =   6
         Left            =   240
         TabIndex        =   7
         Top             =   1560
         Width           =   1215
      End
      Begin VB.CheckBox attributes 
         Caption         =   "压缩"
         Height          =   195
         Index           =   7
         Left            =   240
         TabIndex        =   6
         Top             =   1800
         Width           =   1215
      End
      Begin VB.CheckBox attributes 
         Caption         =   "临时"
         Height          =   195
         Index           =   5
         Left            =   240
         TabIndex        =   5
         Top             =   1320
         Width           =   1215
      End
      Begin VB.CheckBox attributes 
         Caption         =   "存档"
         Height          =   195
         Index           =   4
         Left            =   240
         TabIndex        =   4
         Top             =   1080
         Width           =   1215
      End
      Begin VB.CheckBox attributes 
         Caption         =   "只读"
         Height          =   195
         Index           =   3
         Left            =   240
         TabIndex        =   3
         Top             =   840
         Width           =   1215
      End
      Begin VB.CheckBox attributes 
         Caption         =   "系统"
         Height          =   195
         Index           =   2
         Left            =   240
         TabIndex        =   2
         Top             =   600
         Width           =   1215
      End
      Begin VB.CheckBox attributes 
         Caption         =   "隐藏"
         Height          =   195
         Index           =   1
         Left            =   240
         TabIndex        =   1
         Top             =   360
         Width           =   1215
      End
   End
   Begin VB.Label lblsize 
      Caption         =   "文件大小:"
      Height          =   375
      Left            =   120
      TabIndex        =   17
      Top             =   960
      Width           =   855
   End
   Begin VB.Label lblname 
      Caption         =   "文件名:"
      Height          =   375
      Left            =   120
      TabIndex        =   16
      Top             =   360
      Width           =   735
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub updatestats()
    Dim ftime As SYSTEMTIME
    Dim tfilename As String
    Dim filedata As WIN32_FIND_DATA
    '
    tfilename = dialog.FileName
    filedata = Findfile(tfilename)
    txtname = tfilename
    '
    If filedata.nFileSizeHigh = 0 Then
        txtsize = filedata.nFileSizeLow & " Bytes"
    Else
        txtsize = filedata.nFileSizeHigh & "Bytes"
    End If
    '
    Call FileTimeToSystemTime(filedata.ftCreationTime, ftime)
    lbldate(0) = ftime.wDay & "/" & ftime.wMonth & "/" & ftime.wYear & " " _
        & ftime.wHour & ":" & ftime.wMinute & ":" & ftime.wSecond
    
    Call FileTimeToSystemTime(filedata.ftLastWriteTime, ftime)
    lbldate(1) = ftime.wDay & "/" & ftime.wMonth & "/" & ftime.wYear & " " _
        & ftime.wHour & ":" & ftime.wMinute & ":" & ftime.wSecond
    
    Call FileTimeToSystemTime(filedata.ftLastAccessTime, ftime)
    lbldate(2) = ftime.wDay & "/" & ftime.wMonth & "/" & ftime.wYear
    
    If (filedata.dwFileAttributes And FILE_ATTRIBUTE_HIDDEN) = _
            FILE_ATTRIBUTE_HIDDEN Then
        attributes(1).Value = 1
    Else
        attributes(1).Value = 0
    End If
    If (filedata.dwFileAttributes And FILE_ATTRIBUTE_SYSTEM) = _
            FILE_ATTRIBUTE_SYSTEM Then
        attributes(2).Value = 1
    Else
        attributes(2).Value = 0
    End If
    If (filedata.dwFileAttributes And FILE_ATTRIBUTE_READONLY) = _
            FILE_ATTRIBUTE_READONLY Then
        attributes(3).Value = 1
    Else
        attributes(3).Value = 0
    End If
    If (filedata.dwFileAttributes And FILE_ATTRIBUTE_ARCHIVE) = _
            FILE_ATTRIBUTE_ARCHIVE Then
        attributes(4).Value = 1
    Else
        attributes(4).Value = 0
    End If
    If (filedata.dwFileAttributes And FILE_ATTRIBUTE_TEMPORARY) = _
            FILE_ATTRIBUTE_TEMPORARY Then
        attributes(5).Value = 1
    Else
        attributes(5).Value = 0
    End If
    If (filedata.dwFileAttributes And FILE_ATTRIBUTE_NORMAL) = _
            FILE_ATTRIBUTE_NORMAL Then
        attributes(6).Value = 1
    Else
        attributes(6).Value = 0
    End If
    If (filedata.dwFileAttributes And FILE_ATTRIBUTE_COMPRESSED) = _
            FILE_ATTRIBUTE_COMPRESSED Then
        attributes(7).Value = 1
    Else
        attributes(7).Value = 0
    End If
End Sub
'
Private Sub attributes_GotFocus(Index As Integer)
    ok.SetFocus
End Sub
'
Private Sub Form_Load()
    On Error GoTo errhand
    dialog.ShowOpen
    updatestats
    Me.Show
    ok.SetFocus
    Exit Sub
errhand:
    If Err.Number = cdlCancel Then
        Call MsgBox("You Pressed Cancel!", vbExclamation)
    Else
        Call MsgBox("An error has occured!", vbExclamation)
    End If
    End
End Sub
'
Private Sub ok_Click()
    End
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -