CISA FotoGallery

Statistiche

Tot. visite contenuti : 884419
Home Articoli tecnici General WMI-HardDiskInfo (Informazioni sull'HD)

WMI-HardDiskInfo (Informazioni sull'HD)


Questo Demo mostra come estrarre le caratteristiche dell'HardDisk attraverso la Classe Win32_DiskDrive di WMI.

Per INFO sui Metodi e Proprietà vedere:
 

http://msdn.microsoft.com/en-us/library/windows/desktop/aa394132%28v=vs.85%29.aspx

Public Function retHardDiskInfo()

On Error Resume Next
Dim strComputer As String
Dim objWMIService As Object
Dim objItem As Object
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
For Each objItem In objWMIService.ExecQuery("Select * from Win32_DiskDrive", , 48)
objItem.size = objItem.size / 1000000000
Debug.Print "Hostname:" & vbTab & objItem.SystemName & vbCr & _
"Disk Type: " & vbTab & objItem.InterfaceType & vbCr & _
"Model: " & vbTab & vbTab & objItem.manufacturer & vbCr & _
"Media Type: " & vbTab & objItem.MediaType & vbCr & _
"Disk Number :" & vbTab & objItem.deviceID & vbCr & _
"Disk Size: " & vbTab & objItem.size & " MB" & vbCr & _
"Status: " & vbTab & objItem.Status & vbCr & _
"Partitions: " & vbTab & objItem.Partitions & vbCr & _
"BytesPerSector: " & vbTab & objItem.BytesPerSector & vbCr & _
"TotalCylinders: " & vbTab & objItem.TotalCylinders & vbCr & _
"TotalHeads: " & vbTab & objItem.TotalHeads & vbCr & _
"TotalSectors: " & vbTab & objItem.TotalSectors & vbCr & _
"TotalTracks: " & vbTab & objItem.TotalTracks & vbCr & _
"TracksPerCylinder: " & vbTab & objItem.TracksPerCylinder
Next
Set objItem = Nothing
Set objWMIService = Nothing
End Function


Alessandro Baraldi