⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apivolume.cls

📁 几个不错的VB例子
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "ApiVolume"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True

Private mRootName As String
Private lpVolumeNameBuffer As String
Private nVolumeNameSize As Long
Private lpVolumeSerialNumber As Long
Private lpMaximumComponentLength As Long
Private lpFileSystemFlags As Long
Private lpFileSystemNameBuffer As String
Private nFileSystemNameSize As Long

'\\ API call declarations...
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long


Public Enum FileSystemFlags
     FILE_CASE_SENSITIVE_SEARCH = &H1
     FILE_CASE_PRESERVED_NAMES = &H2
     FILE_UNICODE_ON_DISK = &H4
     FILE_PERSISTENT_ACLS = &H8
     FILE_FILE_COMPRESSION = &H10
     FILE_VOLUME_QUOTAS = &H20
     FILE_SUPPORTS_SPARSE_FILES = &H40
     FILE_SUPPORTS_REPARSE_POINTS = &H80
     FILE_SUPPORTS_REMOTE_STORAGE = &H100
     FILE_VOLUME_IS_COMPRESSED = &H8000
     FILE_SUPPORTS_OBJECT_IDS = &H10000
     FILE_SUPPORTS_ENCRYPTION = &H20000
End Enum

Public Property Get CasePreserved() As Boolean

CasePreserved = (lpFileSystemFlags And FILE_CASE_PRESERVED_NAMES)
    
End Property

Public Property Get CaseSensitive() As Boolean

CaseSensitive = (lpFileSystemFlags And FILE_CASE_SENSITIVE_SEARCH)

End Property


Public Property Get Compressed() As Boolean

Compressed = (lpFileSystemFlags And FILE_VOLUME_IS_COMPRESSED)

End Property

Public Property Get Encryption() As Boolean

Encryption = (lpFileSystemFlags And FILE_SUPPORTS_ENCRYPTION)

End Property

Public Property Get FileCompression() As Boolean

FileCompression = (lpFileSystemFlags And FILE_FILE_COMPRESSION)

End Property

Public Property Get FileSystemName() As String

    If InStr(lpFileSystemNameBuffer, Chr$(0)) > 0 Then
        FileSystemName = Left$(lpFileSystemNameBuffer, InStr(lpFileSystemNameBuffer, Chr$(0)) - 1)
    End If

End Property

Public Property Get ObjectIds() As Boolean

ObjectIds = (lpFileSystemFlags And FILE_SUPPORTS_OBJECT_IDS)

End Property

Public Property Get PersistantACLs() As Boolean

PersistantACLs = (lpFileSystemFlags And FILE_PERSISTENT_ACLS)

End Property

Public Property Get RemoteStorage() As Boolean

RemoteStorage = (lpFileSystemFlags And FILE_SUPPORTS_REMOTE_STORAGE)

End Property

Public Property Get ReparsePoints() As Boolean

ReparsePoints = (lpFileSystemFlags And FILE_SUPPORTS_REPARSE_POINTS)

End Property

Public Property Get RootName() As String

    RootName = mRootName
    
End Property

Public Property Let RootName(ByVal newname As String)

Dim lret As Long

'\\ If the name changes get all the other volume info...
If newname <> mRootName Then
    mRootName = newname
    '\\ Initialise the buffers
    lpVolumeNameBuffer = String$(1024, 0)
    nVolumeNameSize = Len(lpVolumeNameBuffer)
    lpFileSystemNameBuffer = String$(1024, 0)
    nFileSystemNameSize = Len(lpFileSystemNameBuffer)
    lret = GetVolumeInformation(mRootName, lpVolumeNameBuffer, nVolumeNameSize, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize)
    If Err.LastDllError <> 0 Then
        ReportError Err.LastDllError, "ApiVolume:Name (Let)", GetLastSystemError
    End If
End If

End Property

Public Property Get SerialNumber() As Long

    SerialNumber = lpVolumeSerialNumber
    
End Property

Public Property Get SparseFiles() As Boolean

SparseFiles = (lpFileSystemFlags And FILE_SUPPORTS_SPARSE_FILES)

End Property

Public Property Get UnicodeFileTable() As Boolean

UnicodeFileTable = (lpFileSystemFlags And FILE_UNICODE_ON_DISK)

End Property

Public Property Get VolumeName() As String

    If InStr(lpVolumeNameBuffer, Chr$(0)) > 0 Then
        VolumeName = Left$(lpVolumeNameBuffer, InStr(lpVolumeNameBuffer, Chr$(0)) - 1)
    End If
    
End Property


Public Property Get VolumeQuotas() As Boolean

VolumeQuotas = (lpFileSystemFlags And FILE_VOLUME_QUOTAS)

End Property


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -