home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Begin VB.Form frmView Caption = "File Information - " ClientHeight = 4755 ClientLeft = 1560 ClientTop = 1755 ClientWidth = 6075 LinkTopic = "Form2" PaletteMode = 1 'UseZOrder ScaleHeight = 4755 ScaleWidth = 6075 Begin VB.Frame Frame2 Caption = "Times:" Height = 1035 Left = 0 TabIndex = 13 Top = 1020 Width = 4155 Begin VB.Label lblModified Height = 195 Left = 1200 TabIndex = 19 Top = 720 Width = 2895 End Begin VB.Label lblAccessed Height = 195 Left = 1200 TabIndex = 18 Top = 480 Width = 2895 End Begin VB.Label lblCreated Height = 195 Left = 1200 TabIndex = 17 Top = 180 Width = 2895 End Begin VB.Label Label6 Caption = "Modified:" Height = 195 Left = 120 TabIndex = 16 Top = 780 Width = 735 End Begin VB.Label Label5 Caption = "Accessed:" Height = 195 Left = 120 TabIndex = 15 Top = 480 Width = 855 End Begin VB.Label Label4 Caption = "Created:" Height = 195 Left = 120 TabIndex = 14 Top = 180 Width = 675 End End Begin VB.CommandButton cmdClose Cancel = -1 'True Caption = "&Close" Height = 495 Left = 4800 TabIndex = 10 Top = 180 Width = 1215 End Begin VB.Frame Frame1 Caption = "Attributes:" Height = 1035 Left = 60 TabIndex = 4 Top = 2340 Width = 2775 Begin VB.CheckBox chkCompressed Caption = "Compressed" Height = 195 Left = 1440 TabIndex = 9 Top = 420 Width = 1215 End Begin VB.CheckBox chkArchive Caption = "Archive" Height = 195 Left = 1440 TabIndex = 8 Top = 180 Width = 1215 End Begin VB.CheckBox chkSystem Caption = "System" Height = 195 Left = 120 TabIndex = 7 Top = 660 Width = 1035 End Begin VB.CheckBox chkHidden Caption = "Hidden" Height = 195 Left = 120 TabIndex = 6 Top = 420 Width = 1035 End Begin VB.CheckBox chkReadOnly Caption = "Read-Only" Height = 195 Left = 120 TabIndex = 5 Top = 180 Width = 1215 End End Begin VB.Label lblFileSize Height = 255 Left = 960 TabIndex = 12 Top = 720 Width = 3135 End Begin VB.Label Label3 Caption = "File Size:" Height = 195 Left = 60 TabIndex = 11 Top = 720 Width = 855 End Begin VB.Label lblType Height = 195 Left = 1020 TabIndex = 3 Top = 480 Width = 3015 End Begin VB.Label Label2 Caption = "File Type:" Height = 195 Left = 60 TabIndex = 2 Top = 480 Width = 855 End Begin VB.Label lblFileName Caption = "C:\AUTOEXEC.BAT" Height = 195 Left = 1020 TabIndex = 1 Top = 60 Width = 3495 End Begin VB.Label Label1 Caption = "File Name: " Height = 195 Left = 60 TabIndex = 0 Top = 60 Width = 855 End Attribute VB_Name = "frmView" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit ' Copyright 1997 by Desaware Inc. All Rights Reserved Dim hFile&, TaskID& '********************************** '** Function Declarations: #If Win32 Then Private Declare Function GetTimeFormat& Lib "kernel32" Alias "GetTimeFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, lpTime As SYSTEMTIME, ByVal lpFormat As Long, ByVal lpTimeStr As String, ByVal cchTime As Long) Private Declare Function GetDateFormat& Lib "kernel32" Alias "GetDateFormatA" (ByVal Locale As Long, ByVal dwFlags As Long, lpTime As SYSTEMTIME, ByVal lpFormat As Long, ByVal lpTimeStr As String, ByVal cchTime As Long) Private Declare Function FileTimeToSystemTime& Lib "kernel32" (lpFileTime As FILETIME, lpSystemTime As SYSTEMTIME) Private Declare Function CreateFile& Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, ByVal lpSecurityAttributes As Long, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) Private Declare Function GetFileInformationByHandle& Lib "kernel32" (ByVal hFile As Long, lpFileInformation As BY_HANDLE_FILE_INFORMATION) Private Declare Function CloseHandle& Lib "kernel32" (ByVal hObject As Long) Private Declare Function GetBinaryType& Lib "kernel32" (ByVal szFileName As String, fType As Long) Private Declare Function GetWindowsDirectory& Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal myString As String, ByVal nCount As Long) #End If 'WIN32 '********************************** '** Type Definitions: #If Win32 Then Private Type FILETIME dwLowDateTime As Long dwHighDateTime As Long 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 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 #End If 'WIN32 Types '********************************** '** Constant Definitions: #If Win32 Then Private Const SCS_32BIT_BINARY& = 0 Private Const SCS_DOS_BINARY& = 1 Private Const SCS_OS216_BINARY& = 5 Private Const SCS_PIF_BINARY& = 3 Private Const SCS_POSIX_BINARY& = 4 Private Const SCS_WOW_BINARY& = 2 Private Const FILE_ATTRIBUTE_ARCHIVE = &H20 Private Const FILE_ATTRIBUTE_COMPRESSED = &H800 Private Const FILE_ATTRIBUTE_DIRECTORY = &H10 Private Const FILE_ATTRIBUTE_HIDDEN = &H2 Private Const FILE_ATTRIBUTE_NORMAL = &H80 Private Const FILE_ATTRIBUTE_READONLY = &H1 Private Const FILE_ATTRIBUTE_SYSTEM = &H4 Private Const FILE_ATTRIBUTE_TEMPORARY = &H100 Private Const GENERIC_ALL = &H10000000 Private Const GENERIC_EXECUTE = &H20000000 Private Const GENERIC_READ = &H80000000 Private Const GENERIC_WRITE = &H40000000 Private Const OPEN_EXISTING = 3 #End If 'WIN32 Public Sub Initialize(fileName$) Dim dl&, myTime As SYSTEMTIME Dim s$, fType& Dim myFileInfo As BY_HANDLE_FILE_INFORMATION Me.Caption = Me.Caption & fileName lblFileName = fileName$ hFile& = CreateFile&(fileName$, GENERIC_READ Or GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0) dl& = GetBinaryType&(fileName$, fType&) If fType& And SCS_32BIT_BINARY Then lblType = "Win32 Application" ElseIf fType& And SCS_DOS_BINARY Then lblType = "DOS Application" ElseIf fType& And SCS_OS216_BINARY Then lblType = "OS/2 16-Bit Application" ElseIf fType& And SCS_PIF_BINARY Then lblType = "DOS PIF Application" ElseIf fType& And SCS_WOW_BINARY Then lblType = "Win16 Application" Else lblType = "Document" End If dl& = GetFileInformationByHandle&(hFile&, myFileInfo) With myFileInfo If .dwFileAttributes And FILE_ATTRIBUTE_ARCHIVE Then chkArchive = 1 If .dwFileAttributes And FILE_ATTRIBUTE_COMPRESSED Then chkCompressed = 1 If .dwFileAttributes And FILE_ATTRIBUTE_HIDDEN Then chkHidden = 1 If .dwFileAttributes And FILE_ATTRIBUTE_READONLY Then chkReadOnly = 1 If .dwFileAttributes And FILE_ATTRIBUTE_SYSTEM Then chkSystem = 1 dl& = FileTimeToSystemTime(.ftCreationTime, myTime) s$ = String(255, 0) dl& = GetTimeFormat&(&H800, 0, myTime, 0, s$, 254) lblCreated = Left(s$, dl&) s$ = String(255, 0) dl& = GetDateFormat&(&H800, 0, myTime, 0, s$, 254) lblCreated = Left(s$, dl& - 1) & " " & lblCreated dl& = FileTimeToSystemTime(.ftLastAccessTime, myTime) s$ = String(255, 0) dl& = GetTimeFormat&(&H800, 0, myTime, 0, s$, 254) lblAccessed = Left$(s$, dl&) s$ = String(255, 0) dl& = GetDateFormat&(&H800, 0, myTime, 0, s$, 254) lblAccessed = Left(s$, dl& - 1) & " " & lblAccessed dl& = FileTimeToSystemTime(.ftLastWriteTime, myTime) s$ = String(255, 0) dl& = GetTimeFormat&(&H800, 0, myTime, 0, s$, 254) lblModified = Left$(s$, dl&) s$ = String(255, 0) dl& = GetDateFormat&(&H800, 0, myTime, 0, s$, 254) lblModified = Left(s$, dl& - 1) & " " & lblModified lblFileSize = CStr(.nFileSizeLow) & " bytes" End With dl& = CloseHandle&(hFile&) End Sub Private Sub cmdClose_Click() Unload Me End Sub