Make your own free website on Tripod.com

AllApi.net

[an error occurred while processing this directive]
 
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()
    'KPD-Team 2000
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@allapi.net
    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


 
Copyright © 1998-2000, The KPD-Team.
Send mail to KPDTeam@Allapi.net with comments about this web site.
This site is located at
http://www.Allapi.net/