香港新浪網 MySinaBlog
« 上一篇 | 下一篇 »
Emily | 7th Jan 2007, 11:40 AM | Script | (1373 Reads)

WMI Example: Win32_LogicalDisk

All Windows Platforms

 Public Sub ListDriveInfo(strComputer As String)
    On Error Resume Next
    
    Set objWMIService = GetObject("winmgmts://" & strComputer & "/root/CIMV2")
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk", "WQL", _
        wbemFlagReturnImmediately + wbemFlagForwardOnly)
    
    For Each objItem In colItems
        Debug.Print "============================================="
        Debug.Print " " & objItem.Caption
        Debug.Print "============================================="
        Debug.Print "Access: " & objItem.Access
        Debug.Print "Availability: " & objItem.Availability
        Debug.Print "BlockSize: " & objItem.BlockSize
        Debug.Print "Caption: " & objItem.Caption
        Debug.Print "Compressed: " & objItem.Compressed
        Debug.Print "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
        Debug.Print "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
        Debug.Print "CreationClassName: " & objItem.CreationClassName
        Debug.Print "Description: " & objItem.Description
        Debug.Print "DeviceID: " & objItem.DeviceID
        Debug.Print "DriveType: " & objItem.DriveType
        Debug.Print "ErrorCleared: " & objItem.ErrorCleared
        Debug.Print "ErrorDescription: " & objItem.ErrorDescription
        Debug.Print "ErrorMethodology: " & objItem.ErrorMethodology
        Debug.Print "FileSystem: " & objItem.FileSystem
        Debug.Print "FreeSpace: " & objItem.FreeSpace
        Debug.Print "LastErrorCode: " & objItem.LastErrorCode
        Debug.Print "MaximumComponentLength: " & objItem.MaximumComponentLength
        Debug.Print "MediaType: " & objItem.MediaType
        Debug.Print "Name: " & objItem.Name
        Debug.Print "NumberOfBlocks: " & objItem.NumberOfBlocks
        Debug.Print "PNPDeviceID: " & objItem.PNPDeviceID
        strPowerManagementCapabilities = Join(objItem.PowerManagementCapabilities, ",")
        Debug.Print "PowerManagementCapabilities: " & strPowerManagementCapabilities
        Debug.Print "PowerManagementSupported: " & objItem.PowerManagementSupported
        Debug.Print "ProviderName: " & objItem.ProviderName
        Debug.Print "Purpose: " & objItem.Purpose
        Debug.Print "QuotasDisabled: " & objItem.QuotasDisabled
        Debug.Print "QuotasIncomplete: " & objItem.QuotasIncomplete
        Debug.Print "QuotasRebuilding: " & objItem.QuotasRebuilding
        Debug.Print "Size: " & objItem.Size
        Debug.Print "Status: " & objItem.Status
        Debug.Print "StatusInfo: " & objItem.StatusInfo
        Debug.Print "SupportsDiskQuotas: " & objItem.SupportsDiskQuotas
        Debug.Print "SupportsFileBasedCompression: " & objItem.SupportsFileBasedCompression
        Debug.Print "SystemCreationClassName: " & objItem.SystemCreationClassName
        Debug.Print "SystemName: " & objItem.SystemName
        Debug.Print "VolumeDirty: " & objItem.VolumeDirty
        Debug.Print "VolumeName: " & objItem.VolumeName
        Debug.Print "VolumeSerialNumber: " & objItem.VolumeSerialNumber
        Debug.Print
    Next
End Sub
 

Public Sub Test()
    Call ListDriveInfo("Emily")  ' Computer Name
End Sub


'