|
Получение размера диска больше 2Gb |
|
|
Этот код получает емкость и свободное место на диске в байтах при размере диска > 2Гбайт. В качесте sRoot строка с именем диска ("C:\"). Option Explicit
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" _
(ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As LARGE_INTEGER, _
lpTotalNumberOfBytes As LARGE_INTEGER, lpTotalNumberOfFreeBytes As LARGE_INTEGER) As Long
Dim DiskTotalSize As Currency
Dim DiskFreeSize As Currency
Private Type LARGE_INTEGER
bSize(1 To 8) As Byte
End Type
Private Sub Size(sRoot As String)
Dim DiskSizeByte As LARGE_INTEGER
Dim DiskFreeByte As LARGE_INTEGER
Dim DiskCallByte As LARGE_INTEGER
Dim j As Double, i As Integer
If GetDiskFreeSpaceEx(sRoot, DiskCallByte, DiskSizeByte, DiskFreeByte) Then
' Общий размер диска
j = 1: DiskTotalSize = 0
For i = 1 To 8
DiskTotalSize = DiskTotalSize + CCur(DiskSizeByte.bSize(i) * j)
j = j * 256
Next i
' Свободный размер
j = 1: DiskFreeSize = 0
For i = 1 To 8
DiskFreeSize = DiskFreeSize + CCur(DiskFreeByte.bSize(i) * j)
j = j * 256
Next i
Else
' Ошибка - Диск недоступен
DiskFreeSize = 0
DiskTotalSize = 0
End If
End Sub
|
|
|
|
|
|
|