Hi All...
I'm working on a project and I need to pull the total Hard Drive Capacity (Size) in the machine. What I've found so far isn't retrieving the information correctly.. (Ie. 80GB drive is being listed as a 1.18GB) Does anyone have a very reliable way to do this? Thanks...
Her's the code I've tried.
I'm working on a project and I need to pull the total Hard Drive Capacity (Size) in the machine. What I've found so far isn't retrieving the information correctly.. (Ie. 80GB drive is being listed as a 1.18GB) Does anyone have a very reliable way to do this? Thanks...
Her's the code I've tried.
Code:
Private objOS As ManagementObjectSearcher
Private objCS As ManagementObjectSearcher
Private objDS As ManagementObjectSearcher
Private objMgmt As ManagementObject
Private m_strComputerName As String
Private m_strManufacturer As String
Private m_StrModel As String
Private m_strTPM As String
Private m_strAssetTag As String
Private m_strHDCapacity As String
Public Sub New()
objOS = New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
objCS = New ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")
objDS = New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
For Each objMgmt In objOS.Get
m_strComputerName = objMgmt("csname").ToString()
Next
For Each objMgmt In objCS.Get
m_strManufacturer = objMgmt("manufacturer").ToString()
m_StrModel = objMgmt("model").ToString()
m_strTPM = objMgmt("totalphysicalmemory").ToString()
Next
For Each objMgmt In objDS.Get
m_strHDCapacity = objMgmt("size").ToString()
Next
End Sub
Public ReadOnly Property HardDriveSize()
Get
HardDriveSize = m_strHDCapacity
End Get
End Property