Exemple #1
0
        public static string GetManufacturer()
        {
            Win32_BIOS bios = Win32_BIOSReader.Read();

            if (bios != null && bios.Manufacturer != null)
            {
                return(bios.Manufacturer);
            }
            else
            {
                return("Unknwon");
            }
        }
        public static Win32_BIOS Read()
        {
            ManagementObjectSearcher   searcher   = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS");
            ManagementObjectCollection collection = searcher.Get();

            var items = new List <Win32_BIOS>();

            foreach (ManagementObject obj in collection)
            {
                var item = new Win32_BIOS();
                item.BiosCharacteristics  = (ushort[])obj["BiosCharacteristics"];
                item.BIOSVersion          = (string[])obj["BIOSVersion"];
                item.BuildNumber          = (string)obj["BuildNumber"];
                item.Caption              = (string)obj["Caption"];
                item.CodeSet              = (string)obj["CodeSet"];
                item.CurrentLanguage      = (string)obj["CurrentLanguage"];
                item.Description          = (string)obj["Description"];
                item.IdentificationCode   = (string)obj["IdentificationCode"];
                item.InstallableLanguages = (ushort?)obj["InstallableLanguages"];
                item.InstallDate          = (DateTime?)obj["InstallDate"];
                item.LanguageEdition      = (string)obj["LanguageEdition"];
                item.ListOfLanguages      = (string[])obj["ListOfLanguages"];
                item.Manufacturer         = (string)obj["Manufacturer"];
                item.Name                  = (string)obj["Name"];
                item.OtherTargetOS         = (string)obj["OtherTargetOS"];
                item.PrimaryBIOS           = (bool?)obj["PrimaryBIOS"];
                item.ReleaseDate           = (string)obj["ReleaseDate"];
                item.SerialNumber          = (string)obj["SerialNumber"];
                item.SMBIOSBIOSVersion     = (string)obj["SMBIOSBIOSVersion"];
                item.SMBIOSMajorVersion    = (ushort?)obj["SMBIOSMajorVersion"];
                item.SMBIOSMinorVersion    = (ushort?)obj["SMBIOSMinorVersion"];
                item.SMBIOSPresent         = (bool?)obj["SMBIOSPresent"];
                item.SoftwareElementID     = (string)obj["SoftwareElementID"];
                item.SoftwareElementState  = (ushort?)obj["SoftwareElementState"];
                item.Status                = (string)obj["Status"];
                item.TargetOperatingSystem = (ushort?)obj["TargetOperatingSystem"];
                item.Version               = (string)obj["Version"];

                items.Add(item);
            }

            if (items.Count > 0)
            {
                return(items[0]);
            }
            else
            {
                return(null);
            }
        }