Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone have an idea? My code displays the logical disk and not the physical disk of C: .

VB
Private Function GetDiskSize()
        Dim diskSize As Double
        'Dim oConn As ConnectionOptions = New ConnectionOptions()
        'Dim passWord As string
        'oConn.Username = InputBox("User Name Please", "Credentials: Username...")
        'oConn.Password = InputBox("Password Please", "Credentials: Password...")
        Dim oMs As New Management.ManagementScope("\\" & computerName & "\root\cimv2")
        'Dim oMs As System.Management.ManagementScope = New System.Management.ManagementScope("\\" & computerName & "\root\cimv2", oConn)
        Dim query As ObjectQuery
        query = New ObjectQuery("SELECT  Size,   FROM Win32_LogicalDisk where DriveType=3")
        Dim searcher As ManagementObjectSearcher
        searcher = New ManagementObjectSearcher(oMs, query)
        Dim queryCollection As ManagementObjectCollection
        queryCollection = searcher.Get()
        Dim m As ManagementObject
        For Each m In queryCollection
            ' Display the remote computer information
            diskSize = Format(m("size") / 1024 ^ 3, "0.00")
            'diskSize= diskSize.ToString() & " Gb"
            '"Size :" + m("size").ToString
            ''+ vbCrLf + Label1.Text
            'Label2.Text = "FreeSpace :" + m("freespace").ToString
            ''+ vbCrLf + Label2.Text
            'lblRequiredDiskSize.text = "Name : " + m("name")
            '+ vbCrLf + Label3.Text
        Next
        Return diskSize
    End Function
Posted
Updated 25-May-11 11:17am
v2

1 solution

This article:
How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)[^]

shows all of the different bits of info you can get from the ManagementObjectSearcher object that you are sort of using in your code. You could try the Win32_PhysicalMemory one...but I'm not sure if it's exactly what you are looking for.
 
Share this answer
 
Comments
sarovrs 12-Dec-12 0:18am    
It's possible to store system information to database(sql,oracle).how many column to insert to database?????

Thanks For Helping.....
Kschuler 12-Dec-12 9:48am    
I'm not sure I understand your question. If you are storing system information in a database, you'll want to add as many columns as you want. There is A LOT of info that you can get, as you can see from that article. Pick the ones you want and add them to your database. Keep in mind that each one of those listed may have other data stored within it that you may want to separate. You'll have to investigate the ones you are interested in and see for yourself. Good luck.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900