1 | Enum DriveType
|
---|
2 | Unknown = 0
|
---|
3 | NoRootDirectory
|
---|
4 | Removable
|
---|
5 | Fixed
|
---|
6 | CDRom
|
---|
7 | Network
|
---|
8 | Ram
|
---|
9 | End Enum
|
---|
10 |
|
---|
11 | Class DriveInfo
|
---|
12 | m_DriveName As String
|
---|
13 | Public
|
---|
14 | Sub DriveInfo(driveName As String)
|
---|
15 | If driveName.Length <> 1 Then
|
---|
16 | 'ArgumentException
|
---|
17 | debug
|
---|
18 | End If
|
---|
19 | driveName.ToUpper()
|
---|
20 | m_DriveName = driveName + ":\"
|
---|
21 | End Sub
|
---|
22 |
|
---|
23 | Sub ~DriveInfo()
|
---|
24 | End Sub
|
---|
25 |
|
---|
26 | 'property
|
---|
27 | Function AvailableFreeSpace() As QWord
|
---|
28 | Dim availableFreeSpace As ULARGE_INTEGER
|
---|
29 | If GetDiskFreeSpaceEx(m_DriveName, availableFreeSpace, ByVal 0, ByVal 0) Then
|
---|
30 | Return (availableFreeSpace.HighPart << 32) Or availableFreeSpace.LowPart
|
---|
31 | Else
|
---|
32 | 'IOException
|
---|
33 | End If
|
---|
34 | End Function
|
---|
35 |
|
---|
36 | Function DriveFormat() As String
|
---|
37 | Dim systemName As String
|
---|
38 | systemName.ReSize(15)
|
---|
39 | If GetVolumeInformation(m_DriveName, NULL, NULL, NULL, NULL, NULL, systemName, 16) Then
|
---|
40 | Return systemName
|
---|
41 | Else
|
---|
42 | 'IOException
|
---|
43 | End If
|
---|
44 | End Function
|
---|
45 |
|
---|
46 | Function DriveType() As Long
|
---|
47 | Return GetDriveType(m_DriveName)
|
---|
48 | End Function
|
---|
49 |
|
---|
50 | Function IsReady() As BOOL
|
---|
51 | If GetVolumeInformation(m_DriveName, NULL, NULL, NULL, NULL, NULL, NULL, NULL) Then
|
---|
52 | Return _System_TRUE
|
---|
53 | Else
|
---|
54 | Return _System_FALSE
|
---|
55 | End If
|
---|
56 | End Function
|
---|
57 |
|
---|
58 | Function Name() As String
|
---|
59 | Return m_DriveName
|
---|
60 | End Function
|
---|
61 |
|
---|
62 | /* Function RootDirectory() As DirectoryInfo
|
---|
63 | End Function*/
|
---|
64 |
|
---|
65 | Function TotalFreeSpace() As QWord
|
---|
66 | Dim totalFreeSpace As ULARGE_INTEGER
|
---|
67 | If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, ByVal 0, totalFreeSpace) Then
|
---|
68 | Return (totalFreeSpace.HighPart << 32) Or totalFreeSpace.LowPart
|
---|
69 | Else
|
---|
70 | 'IOException
|
---|
71 | End If
|
---|
72 | End Function
|
---|
73 |
|
---|
74 | Function TotalSize() As QWord
|
---|
75 | Dim totalSize As ULARGE_INTEGER
|
---|
76 | If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, totalSize, ByVal 0) Then
|
---|
77 | Return (totalSize.HighPart << 32) Or totalSize.LowPart
|
---|
78 | Else
|
---|
79 | 'IOException
|
---|
80 | End If
|
---|
81 | End Function
|
---|
82 |
|
---|
83 | Function VolumeLabel() As String
|
---|
84 | Dim volumeName As String
|
---|
85 | volumeName.ReSize(63)
|
---|
86 | If GetVolumeInformation(m_DriveName, volumeName, 64, NULL, NULL, NULL, NULL, NULL) Then
|
---|
87 | Return volumeName
|
---|
88 | Else
|
---|
89 | 'IOException
|
---|
90 | End If
|
---|
91 | End Function
|
---|
92 | End Class
|
---|