首先VB貌似没有unsigned long类型,大小超过2G就变负数了,有办法表示大于2G的数么?
然后如果一个文件超过4G该怎么操作啊。。

解决方案 »

  1.   

    使用API,可以读写 2^64字节的文件
      

  2.   

    给你一个API的例子,注意里面的CurrencyOption Explicit
    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: [email protected]
        Dim hFile As Long, nSize As Currency, sSave As String
        'open the file
        hFile = CreateFile("c:\boot.ini", 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
      

  3.   

    请具体点说是哪个API,这样大家都省时间:)
      

  4.   

    额。。我就是不知道用哪个API呀
    如何用API操作大于4G的文件