Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys

pls any one tell me to how to get bios no, hard disk no, mother board no in the c# desktop application
Posted

You might try using WMI, as follows:
using Microsoft.Win32;

ManagementObjectSearcher searcher = 
    new ManagementObjectSearcher(@"\\.\root\cimv2",
                                 "SELECT * FROM Win32_BIOS"));

foreach (var _object in searcher.Get())
{
    if (_object != null)
    {
        try
        {
            string object_name = "?";
            
            if (_object["Name"] != null)
            {
                object_name = _object["Name"].ToString();
            }
            else if (_object["Caption"] != null)
            {
                object_name = _object["Caption"].ToString();
            }
            else if (_object["Description"] != null)
            {
                object_name = _object["Description"].ToString();
            }
            
            foreach (var property in _object.Properties)
            {
                string property_name  = property.Name;

                if ((property.Value != null) &&
                    (!property_name.Contains("CreationClassName")))
                {
                    string property_value;
                    
                    if (!(property.Value is Array))
                    {
                        property_value = property.Value.ToString();
                    }
                    else
                    {
                        StringBuilder _property_value = new StringBuilder();
                        
                        Array _property_array = property.Value as Array;
                        
                        int count = 0;
                        
                        foreach (var entry in _property_array)
                        {
                            if (count > 0) _property_value.Append(",\r\n");
                            _property_value.Append(entry.ToString());
                            count++;
                        }

                        property_value = _property_value.ToString();
                    }
                }
            }
        }
        
        catch (ManagementException exception)
        {
            System.Diagnostics.Trace.WriteLine(exception.ToString());
        }
    }
}
This logic shows how to enumerate most of the information available in WMI about the BIOS.
 
Share this answer
 
Comments
Amir Mahfoozi 24-Dec-11 6:29am    
+5
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

A simple query using a search string copied from your question found loads of exampoles:
http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=bios+no%2C+hard+disk+no%2C+mother+board+no+in+the+c%23[^]

Please try to do at least basic research yourself in future, so as not to waste your time or ours.
 
Share this answer
 

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