Click here to Skip to main content
13,258,269 members (43,525 online)
Rate this:
 
Please Sign up or sign in to vote.
Does anyone have an idea? My code displays the logical disk and not the physical disk of C: .

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 25-May-11 11:29am
Updated 25-May-11 12:17pm
Kschuler35.6K
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Member 9544284 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 25 May 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100