Const GENERIC_READ = &H80000000
Const FILE_SHARE_READ = &H1
Const OPEN_EXISTING = 3
Const FILE_TYPE_CHAR = &H2
Const FILE_TYPE_DISK = &H1
Const FILE_TYPE_PIPE = &H3
Const FILE_TYPE_UNKNOWN = &H0
Private Declare Function GetFileType Lib "kernel32" (ByVal hFile As Long) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function GetFileSizeEx Lib "kernel32" (ByVal hFile As Long, lpFileSize As Currency) As Boolean
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub Form_Paint()
'E-Mail: [email protected]
Dim hFile As Long, nSize As Currency, sSave As String
'open the file
hFile = CreateFile("c:\autoexec.bat", GENERIC_READ, FILE_SHARE_READ, ByVal 0&, OPEN_EXISTING, ByVal 0&, ByVal 0&)
'get the filesize
GetFileSizeEx hFile, nSize
'retrieve the file type
Select Case GetFileType(hFile)
Case FILE_TYPE_UNKNOWN
sSave = "The type of the specified file is unknown"
Case FILE_TYPE_DISK
sSave = "The specified file is a disk file"
Case FILE_TYPE_CHAR
sSave = "The specified file is a character file, typically an LPT device or a console"
Case FILE_TYPE_PIPE
sSave = "The specified file is either a named or anonymous pipe"
End Select
'close the file
CloseHandle hFile
MsgBox "File Type: " + sSave + vbCrLf + "Size:" + Str$(nSize * 10000) + " bytes"
End Sub
Const FILE_SHARE_READ = &H1
Const OPEN_EXISTING = 3
Const FILE_TYPE_CHAR = &H2
Const FILE_TYPE_DISK = &H1
Const FILE_TYPE_PIPE = &H3
Const FILE_TYPE_UNKNOWN = &H0
Private Declare Function GetFileType Lib "kernel32" (ByVal hFile As Long) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function GetFileSizeEx Lib "kernel32" (ByVal hFile As Long, lpFileSize As Currency) As Boolean
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Sub Form_Paint()
'E-Mail: [email protected]
Dim hFile As Long, nSize As Currency, sSave As String
'open the file
hFile = CreateFile("c:\autoexec.bat", GENERIC_READ, FILE_SHARE_READ, ByVal 0&, OPEN_EXISTING, ByVal 0&, ByVal 0&)
'get the filesize
GetFileSizeEx hFile, nSize
'retrieve the file type
Select Case GetFileType(hFile)
Case FILE_TYPE_UNKNOWN
sSave = "The type of the specified file is unknown"
Case FILE_TYPE_DISK
sSave = "The specified file is a disk file"
Case FILE_TYPE_CHAR
sSave = "The specified file is a character file, typically an LPT device or a console"
Case FILE_TYPE_PIPE
sSave = "The specified file is either a named or anonymous pipe"
End Select
'close the file
CloseHandle hFile
MsgBox "File Type: " + sSave + vbCrLf + "Size:" + Str$(nSize * 10000) + " bytes"
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货