0

我试图从笔记本中获取有关硬件的信息。我通过 WMI 执行此操作,但并不总是包含有关笔记本型号的信息。这取决于制造商,SONY 从不包含 WMI 中的硬件信息。

            FileStream fs = new FileStream(@"C:\log.txt", FileMode.OpenOrCreate);
        StreamWriter sw = new StreamWriter(fs);
        string[] Names = { "Win32_Fan", "Win32_HeatPipe", "Win32_Refrigeration", "Win32_TemperatureProbe", "Win32_Keyboard", "Win32_PointingDevice",
                             "Win32_AutochkSetting", "Win32_CDROMDrive" , "Win32_DiskDrive" ,"Win32_FloppyDrive", "Win32_PhysicalMedia","Win32_TapeDrive" ,
                         "Win32_1394Controller","Win32_1394ControllerDevice", "Win32_AllocatedResource", "Win32_AssociatedProcessorMemory","Win32_BaseBoard",
                         "Win32_BIOS", "Win32_Bus","Win32_CacheMemory","Win32_ControllerHasHub","Win32_DeviceBus","Win32_DeviceMemoryAddress", "Win32_DeviceSettings",
                         "Win32_DMAChannel","Win32_FloppyController","Win32_IDEController","Win32_IDEControllerDevice","Win32_InfraredDevice","Win32_IRQResource","Win32_MemoryArray",
                         "Win32_MemoryArrayLocation","Win32_MemoryDevice","Win32_MemoryDeviceArray","Win32_MemoryDeviceLocation","Win32_MotherboardDevice","Win32_OnBoardDevice",
                         "Win32_ParallelPort","Win32_PCMCIAController","Win32_PhysicalMemory","Win32_PhysicalMemoryArray","Win32_PhysicalMemoryLocation","Win32_PNPAllocatedResource",
                         "Win32_PNPDevice","Win32_PNPEntity","Win32_PortConnector","Win32_PortResource","Win32_Processor","Win32_SCSIController", "Win32_SCSIControllerDevice","Win32_SerialPort",
                         "Win32_SerialPortConfiguration","Win32_SerialPortSetting","Win32_SMBIOSMemory","Win32_SoundDevice","Win32_SystemBIOS","Win32_SystemDriverPNPEntity","Win32_SystemEnclosure",
                         "Win32_SystemMemoryResource","Win32_SystemSlot","Win32_USBController","Win32_USBControllerDevice","Win32_USBHub","Win32_NetworkAdapter",
                         "Win32_NetworkAdapterConfiguration","Win32_NetworkAdapterSetting","Win32_Battery","Win32_CurrentProbe","Win32_PortableBattery",
                         "Win32_PowerManagementEvent","Win32_VoltageProbe","Win32_DriverForDevice","Win32_Printer","Win32_PrinterConfiguration","Win32_PrinterController",
                         "Win32_PrinterDriver","Win32_PrinterDriverDll","Win32_PrinterSetting","Win32_PrintJob","Win32_TCPIPPrinterPort","Win32_POTSModem","Win32_POTSModemToSerialPort",
                         "Win32_DesktopMonitor","Win32_DisplayConfiguration","Win32_DisplayControllerConfiguration","Win32_VideoConfiguration","Win32_VideoController","Win32_VideoSettings"};

        foreach (string name in Names)
        {
            sw.WriteLine("                                                                           ");
            sw.WriteLine("<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            sw.WriteLine(name);
            sw.WriteLine("<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM " + name);
            ManagementObjectCollection information = searcher.Get();

            foreach (ManagementObject obj in information)
            {

                foreach (PropertyData data in obj.Properties)
                {

                    sw.WriteLine("{0} = {1}", data.Name, data.Value);
                }
            }

        }
        sw.Close();

我在哪里可以获得这些信息?谢谢!

4

2 回答 2

1

您可以尝试从 BIOS 信息中获取此信息,该信息存储在注册表中的HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS. 它应该在 SystemProductNameorSystemVersion值中。

于 2013-05-16T03:16:30.573 回答
0

型号和序列号包含在“Win32_ComputerSystemProduct”中。

于 2013-05-16T11:58:55.773 回答