home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
- Begin VB.Form Form1
- Caption = "File Information"
- ClientHeight = 2910
- ClientLeft = 60
- ClientTop = 330
- ClientWidth = 6030
- LinkTopic = "Form1"
- ScaleHeight = 2910
- ScaleWidth = 6030
- StartUpPosition = 3 'Windows Default
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 345
- Top = 2235
- _ExtentX = 847
- _ExtentY = 847
- _Version = 393216
- FontSize = 1.17491e-38
- End
- Begin VB.Frame Frame1
- Caption = "File Attributes"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1815
- Left = 120
- TabIndex = 1
- Top = 120
- Width = 5655
- Begin VB.Label Label7
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 2310
- TabIndex = 7
- Top = 1320
- Width = 2985
- End
- Begin VB.Label Label6
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 2310
- TabIndex = 6
- Top = 840
- Width = 2985
- End
- Begin VB.Label Label5
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 2310
- TabIndex = 5
- Top = 360
- Width = 2985
- End
- Begin VB.Label Label3
- Caption = "File Size:"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 120
- TabIndex = 4
- Top = 1320
- Width = 855
- End
- Begin VB.Label Label2
- Caption = "File Attributes:"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 120
- TabIndex = 3
- Top = 840
- Width = 1695
- End
- Begin VB.Label Label1
- Caption = "File Name:"
- BeginProperty Font
- Name = "Verdana"
- Size = 9
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 120
- TabIndex = 2
- Top = 360
- Width = 975
- End
- End
- Begin VB.CommandButton Command1
- Caption = "Get File Info"
- BeginProperty Font
- Name = "Verdana"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 495
- Left = 3345
- TabIndex = 0
- Top = 2280
- Width = 2415
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- Option Explicit
- Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" _
- (ByVal lpFileName As String) As Long
- Private Declare Function GetFullPathName Lib "kernel32" Alias "GetFullPathNameA" _
- (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, _
- ByVal lpFilePart As String) As Long
- Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
- (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, _
- ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Any, _
- ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, _
- ByVal hTemplateFile As Long) As Long
- Private Declare Function GetFileSize Lib "kernel32" _
- (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
- Private Declare Function CloseHandle Lib "kernel32" _
- (ByVal hObject As Long) As Long
- Const FILE_ATTRIBUTE_ARCHIVE = &H20
- Const FILE_ATTRIBUTE_COMPRESSED = &H800
- Const FILE_ATTRIBUTE_DIRECTORY = &H10
- Const FILE_ATTRIBUTE_HIDDEN = &H2
- Const FILE_ATTRIBUTE_NORMAL = &H80
- Const FILE_ATTRIBUTE_READONLY = &H1
- Const FILE_ATTRIBUTE_SYSTEM = &H4
- Const GENERIC_READ = &H80000000
- Const OPEN_EXISTING = 3
- Const GENERIC_WRITE = &H40000000
- Private Sub Command1_Click()
- Dim retValue As Long
- Dim filePath As String * 255
- Dim attrFlag As Long
- Dim attrStr As String, fileName As String
- Dim filePointer As Long, fileSize As Long
- CommonDialog1.ShowOpen
- If CommonDialog1.fileName <> "" Then fileName = CommonDialog1.fileName
- 'Get full path for file name
- retValue = GetFullPathName(fileName, 255, filePath, 0)
- Label5.Caption = filePath
- 'Get file attributes
- attrFlag = GetFileAttributes(fileName)
- If (attrFlag And FILE_ATTRIBUTE_ARCHIVE) Then attrStr = "A"
- If (attrFlag And FILE_ATTRIBUTE_COMPRESSED) Then attrStr = attrStr & "C"
- If (attrFlag And FILE_ATTRIBUTE_DIRECTORY) Then attrStr = attrStr & "D"
- If (attrFlag And FILE_ATTRIBUTE_HIDDEN) Then attrStr = attrStr & "H"
- If (attrFlag And FILE_ATTRIBUTE_NORMAL) Then attrStr = attrStr & "N"
- If (attrFlag And FILE_ATTRIBUTE_READONLY) Then attrStr = attrStr & "R"
- If (attrFlag And FILE_ATTRIBUTE_SYSTEM) Then attrStr = attrStr & "S"
- Label6.Caption = attrStr
- 'Get file size
- filePointer = CreateFile(fileName, GENERIC_READ Or GENERIC_WRITE, 0&, 0&, OPEN_EXISTING, _
- FILE_ATTRIBUTE_NORMAL, 0&)
-
- fileSize = GetFileSize(filePointer, 0&)
- Label7.Caption = fileSize
- CloseHandle (filePointer)
- End Sub
-