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[15] As TCHAR
|
---|
38 | If GetVolumeInformation(m_DriveName, NULL, NULL, NULL, NULL, NULL, systemName, Len (systemName)) Then
|
---|
39 | Return systemName
|
---|
40 | Else
|
---|
41 | 'IOException
|
---|
42 | End If
|
---|
43 | End Function
|
---|
44 |
|
---|
45 | Function DriveType() As Long
|
---|
46 | Return GetDriveType(m_DriveName)
|
---|
47 | End Function
|
---|
48 |
|
---|
49 | Function IsReady() As Boolean
|
---|
50 | If GetVolumeInformation(m_DriveName, NULL, NULL, NULL, NULL, NULL, NULL, NULL) Then
|
---|
51 | Return True
|
---|
52 | Else
|
---|
53 | Return False
|
---|
54 | End If
|
---|
55 | End Function
|
---|
56 |
|
---|
57 | Function Name() As String
|
---|
58 | Return m_DriveName
|
---|
59 | End Function
|
---|
60 |
|
---|
61 | /* Function RootDirectory() As DirectoryInfo
|
---|
62 | End Function*/
|
---|
63 |
|
---|
64 | Function TotalFreeSpace() As QWord
|
---|
65 | Dim totalFreeSpace As ULARGE_INTEGER
|
---|
66 | If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, ByVal 0, totalFreeSpace) Then
|
---|
67 | Return (totalFreeSpace.HighPart << 32) Or totalFreeSpace.LowPart
|
---|
68 | Else
|
---|
69 | 'IOException
|
---|
70 | End If
|
---|
71 | End Function
|
---|
72 |
|
---|
73 | Function TotalSize() As QWord
|
---|
74 | Dim totalSize As ULARGE_INTEGER
|
---|
75 | If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, totalSize, ByVal 0) Then
|
---|
76 | Return (totalSize.HighPart << 32) Or totalSize.LowPart
|
---|
77 | Else
|
---|
78 | 'IOException
|
---|
79 | End If
|
---|
80 | End Function
|
---|
81 |
|
---|
82 | Function VolumeLabel() As String
|
---|
83 | Dim volumeName[63] As TCAHR
|
---|
84 | If GetVolumeInformation(m_DriveName, volumeName, 64, NULL, NULL, NULL, NULL, NULL) Then
|
---|
85 | Return volumeName
|
---|
86 | Else
|
---|
87 | 'IOException
|
---|
88 | End If
|
---|
89 | End Function
|
---|
90 | End Class
|
---|