none
numero de serie fisico de disco duro

Respuestas

  • Con esto puede obtener todas las informaciones del disco. Para el numero de serie verificate la parte en negrita

    using System;
    using System.Management;
    using System.Windows.Forms;
    
    namespace WMISample
    {
        public class MyWMIQuery
        {
            public static void Main()
            {
                try
                {
                    ManagementObjectSearcher searcher = 
                        new ManagementObjectSearcher("root\\CIMV2", 
                        "SELECT * FROM Win32_DiskDrive"); 
    
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        Console.WriteLine("-----------------------------------");
                        Console.WriteLine("Win32_DiskDrive instance");
                        Console.WriteLine("-----------------------------------");
                        Console.WriteLine("Availability: {0}", queryObj["Availability"]);
                        Console.WriteLine("BytesPerSector: {0}", queryObj["BytesPerSector"]);
    
                        if(queryObj["Capabilities"] == null)
                            Console.WriteLine("Capabilities: {0}", queryObj["Capabilities"]);
                        else
                        {
                            UInt16[] arrCapabilities = (UInt16[])(queryObj["Capabilities"]);
                            foreach (UInt16 arrValue in arrCapabilities)
                            {
                                Console.WriteLine("Capabilities: {0}", arrValue);
                            }
                        }
    
                        if(queryObj["CapabilityDescriptions"] == null)
                            Console.WriteLine("CapabilityDescriptions: {0}", queryObj["CapabilityDescriptions"]);
                        else
                        {
                            String[] arrCapabilityDescriptions = (String[])(queryObj["CapabilityDescriptions"]);
                            foreach (String arrValue in arrCapabilityDescriptions)
                            {
                                Console.WriteLine("CapabilityDescriptions: {0}", arrValue);
                            }
                        }
                        Console.WriteLine("Caption: {0}", queryObj["Caption"]);
                        Console.WriteLine("CompressionMethod: {0}", queryObj["CompressionMethod"]);
                        Console.WriteLine("ConfigManagerErrorCode: {0}", queryObj["ConfigManagerErrorCode"]);
                        Console.WriteLine("ConfigManagerUserConfig: {0}", queryObj["ConfigManagerUserConfig"]);
                        Console.WriteLine("CreationClassName: {0}", queryObj["CreationClassName"]);
                        Console.WriteLine("DefaultBlockSize: {0}", queryObj["DefaultBlockSize"]);
                        Console.WriteLine("Description: {0}", queryObj["Description"]);
                        Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);
                        Console.WriteLine("ErrorCleared: {0}", queryObj["ErrorCleared"]);
                        Console.WriteLine("ErrorDescription: {0}", queryObj["ErrorDescription"]);
                        Console.WriteLine("ErrorMethodology: {0}", queryObj["ErrorMethodology"]);
                        Console.WriteLine("FirmwareRevision: {0}", queryObj["FirmwareRevision"]);
                        Console.WriteLine("Index: {0}", queryObj["Index"]);
                        Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);
                        Console.WriteLine("InterfaceType: {0}", queryObj["InterfaceType"]);
                        Console.WriteLine("LastErrorCode: {0}", queryObj["LastErrorCode"]);
                        Console.WriteLine("Manufacturer: {0}", queryObj["Manufacturer"]);
                        Console.WriteLine("MaxBlockSize: {0}", queryObj["MaxBlockSize"]);
                        Console.WriteLine("MaxMediaSize: {0}", queryObj["MaxMediaSize"]);
                        Console.WriteLine("MediaLoaded: {0}", queryObj["MediaLoaded"]);
                        Console.WriteLine("MediaType: {0}", queryObj["MediaType"]);
                        Console.WriteLine("MinBlockSize: {0}", queryObj["MinBlockSize"]);
                        Console.WriteLine("Model: {0}", queryObj["Model"]);
                        Console.WriteLine("Name: {0}", queryObj["Name"]);
                        Console.WriteLine("NeedsCleaning: {0}", queryObj["NeedsCleaning"]);
                        Console.WriteLine("NumberOfMediaSupported: {0}", queryObj["NumberOfMediaSupported"]);
                        Console.WriteLine("Partitions: {0}", queryObj["Partitions"]);
                        Console.WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);
    
                        if(queryObj["PowerManagementCapabilities"] == null)
                            Console.WriteLine("PowerManagementCapabilities: {0}", queryObj["PowerManagementCapabilities"]);
                        else
                        {
                            UInt16[] arrPowerManagementCapabilities = (UInt16[])(queryObj["PowerManagementCapabilities"]);
                            foreach (UInt16 arrValue in arrPowerManagementCapabilities)
                            {
                                Console.WriteLine("PowerManagementCapabilities: {0}", arrValue);
                            }
                        }
                        Console.WriteLine("PowerManagementSupported: {0}", queryObj["PowerManagementSupported"]);
                        Console.WriteLine("SCSIBus: {0}", queryObj["SCSIBus"]);
                        Console.WriteLine("SCSILogicalUnit: {0}", queryObj["SCSILogicalUnit"]);
                        Console.WriteLine("SCSIPort: {0}", queryObj["SCSIPort"]);
                        Console.WriteLine("SCSITargetId: {0}", queryObj["SCSITargetId"]);
                        Console.WriteLine("SectorsPerTrack: {0}", queryObj["SectorsPerTrack"]);
                        Console.WriteLine("SerialNumber: {0}", queryObj["SerialNumber"]);
                        Console.WriteLine("Signature: {0}", queryObj["Signature"]);
                        Console.WriteLine("Size: {0}", queryObj["Size"]);
                        Console.WriteLine("Status: {0}", queryObj["Status"]);
                        Console.WriteLine("StatusInfo: {0}", queryObj["StatusInfo"]);
                        Console.WriteLine("SystemCreationClassName: {0}", queryObj["SystemCreationClassName"]);
                        Console.WriteLine("SystemName: {0}", queryObj["SystemName"]);
                        Console.WriteLine("TotalCylinders: {0}", queryObj["TotalCylinders"]);
                        Console.WriteLine("TotalHeads: {0}", queryObj["TotalHeads"]);
                        Console.WriteLine("TotalSectors: {0}", queryObj["TotalSectors"]);
                        Console.WriteLine("TotalTracks: {0}", queryObj["TotalTracks"]);
                        Console.WriteLine("TracksPerCylinder: {0}", queryObj["TracksPerCylinder"]);
                    }
                }
                catch (ManagementException e)
                {
                    MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
                }
            }
        }
    }


    Angel R. Jimenez G.
    Software Development
    Santo Domingo
    Republica Dominicana
    Blog

    lunes, 22 de octubre de 2012 23:08
  • hola

    esa misma pregunta se respondio varias veces en el foro

    http://social.msdn.microsoft.com/Forums/es/vbes/thread/20a85809-4308-48c5-8f90-a579b6329d46

    http://social.msdn.microsoft.com/Forums/es/vbes/thread/2c84c914-8524-481c-ba51-2b6a2e698980

    saludos


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina

    • Marcado como respuesta Eder CostaOwner martes, 13 de noviembre de 2012 12:46
    martes, 23 de octubre de 2012 0:06

Todas las respuestas

  • Con esto puede obtener todas las informaciones del disco. Para el numero de serie verificate la parte en negrita

    using System;
    using System.Management;
    using System.Windows.Forms;
    
    namespace WMISample
    {
        public class MyWMIQuery
        {
            public static void Main()
            {
                try
                {
                    ManagementObjectSearcher searcher = 
                        new ManagementObjectSearcher("root\\CIMV2", 
                        "SELECT * FROM Win32_DiskDrive"); 
    
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        Console.WriteLine("-----------------------------------");
                        Console.WriteLine("Win32_DiskDrive instance");
                        Console.WriteLine("-----------------------------------");
                        Console.WriteLine("Availability: {0}", queryObj["Availability"]);
                        Console.WriteLine("BytesPerSector: {0}", queryObj["BytesPerSector"]);
    
                        if(queryObj["Capabilities"] == null)
                            Console.WriteLine("Capabilities: {0}", queryObj["Capabilities"]);
                        else
                        {
                            UInt16[] arrCapabilities = (UInt16[])(queryObj["Capabilities"]);
                            foreach (UInt16 arrValue in arrCapabilities)
                            {
                                Console.WriteLine("Capabilities: {0}", arrValue);
                            }
                        }
    
                        if(queryObj["CapabilityDescriptions"] == null)
                            Console.WriteLine("CapabilityDescriptions: {0}", queryObj["CapabilityDescriptions"]);
                        else
                        {
                            String[] arrCapabilityDescriptions = (String[])(queryObj["CapabilityDescriptions"]);
                            foreach (String arrValue in arrCapabilityDescriptions)
                            {
                                Console.WriteLine("CapabilityDescriptions: {0}", arrValue);
                            }
                        }
                        Console.WriteLine("Caption: {0}", queryObj["Caption"]);
                        Console.WriteLine("CompressionMethod: {0}", queryObj["CompressionMethod"]);
                        Console.WriteLine("ConfigManagerErrorCode: {0}", queryObj["ConfigManagerErrorCode"]);
                        Console.WriteLine("ConfigManagerUserConfig: {0}", queryObj["ConfigManagerUserConfig"]);
                        Console.WriteLine("CreationClassName: {0}", queryObj["CreationClassName"]);
                        Console.WriteLine("DefaultBlockSize: {0}", queryObj["DefaultBlockSize"]);
                        Console.WriteLine("Description: {0}", queryObj["Description"]);
                        Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);
                        Console.WriteLine("ErrorCleared: {0}", queryObj["ErrorCleared"]);
                        Console.WriteLine("ErrorDescription: {0}", queryObj["ErrorDescription"]);
                        Console.WriteLine("ErrorMethodology: {0}", queryObj["ErrorMethodology"]);
                        Console.WriteLine("FirmwareRevision: {0}", queryObj["FirmwareRevision"]);
                        Console.WriteLine("Index: {0}", queryObj["Index"]);
                        Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);
                        Console.WriteLine("InterfaceType: {0}", queryObj["InterfaceType"]);
                        Console.WriteLine("LastErrorCode: {0}", queryObj["LastErrorCode"]);
                        Console.WriteLine("Manufacturer: {0}", queryObj["Manufacturer"]);
                        Console.WriteLine("MaxBlockSize: {0}", queryObj["MaxBlockSize"]);
                        Console.WriteLine("MaxMediaSize: {0}", queryObj["MaxMediaSize"]);
                        Console.WriteLine("MediaLoaded: {0}", queryObj["MediaLoaded"]);
                        Console.WriteLine("MediaType: {0}", queryObj["MediaType"]);
                        Console.WriteLine("MinBlockSize: {0}", queryObj["MinBlockSize"]);
                        Console.WriteLine("Model: {0}", queryObj["Model"]);
                        Console.WriteLine("Name: {0}", queryObj["Name"]);
                        Console.WriteLine("NeedsCleaning: {0}", queryObj["NeedsCleaning"]);
                        Console.WriteLine("NumberOfMediaSupported: {0}", queryObj["NumberOfMediaSupported"]);
                        Console.WriteLine("Partitions: {0}", queryObj["Partitions"]);
                        Console.WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);
    
                        if(queryObj["PowerManagementCapabilities"] == null)
                            Console.WriteLine("PowerManagementCapabilities: {0}", queryObj["PowerManagementCapabilities"]);
                        else
                        {
                            UInt16[] arrPowerManagementCapabilities = (UInt16[])(queryObj["PowerManagementCapabilities"]);
                            foreach (UInt16 arrValue in arrPowerManagementCapabilities)
                            {
                                Console.WriteLine("PowerManagementCapabilities: {0}", arrValue);
                            }
                        }
                        Console.WriteLine("PowerManagementSupported: {0}", queryObj["PowerManagementSupported"]);
                        Console.WriteLine("SCSIBus: {0}", queryObj["SCSIBus"]);
                        Console.WriteLine("SCSILogicalUnit: {0}", queryObj["SCSILogicalUnit"]);
                        Console.WriteLine("SCSIPort: {0}", queryObj["SCSIPort"]);
                        Console.WriteLine("SCSITargetId: {0}", queryObj["SCSITargetId"]);
                        Console.WriteLine("SectorsPerTrack: {0}", queryObj["SectorsPerTrack"]);
                        Console.WriteLine("SerialNumber: {0}", queryObj["SerialNumber"]);
                        Console.WriteLine("Signature: {0}", queryObj["Signature"]);
                        Console.WriteLine("Size: {0}", queryObj["Size"]);
                        Console.WriteLine("Status: {0}", queryObj["Status"]);
                        Console.WriteLine("StatusInfo: {0}", queryObj["StatusInfo"]);
                        Console.WriteLine("SystemCreationClassName: {0}", queryObj["SystemCreationClassName"]);
                        Console.WriteLine("SystemName: {0}", queryObj["SystemName"]);
                        Console.WriteLine("TotalCylinders: {0}", queryObj["TotalCylinders"]);
                        Console.WriteLine("TotalHeads: {0}", queryObj["TotalHeads"]);
                        Console.WriteLine("TotalSectors: {0}", queryObj["TotalSectors"]);
                        Console.WriteLine("TotalTracks: {0}", queryObj["TotalTracks"]);
                        Console.WriteLine("TracksPerCylinder: {0}", queryObj["TracksPerCylinder"]);
                    }
                }
                catch (ManagementException e)
                {
                    MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
                }
            }
        }
    }


    Angel R. Jimenez G.
    Software Development
    Santo Domingo
    Republica Dominicana
    Blog

    lunes, 22 de octubre de 2012 23:08
  • hola

    esa misma pregunta se respondio varias veces en el foro

    http://social.msdn.microsoft.com/Forums/es/vbes/thread/20a85809-4308-48c5-8f90-a579b6329d46

    http://social.msdn.microsoft.com/Forums/es/vbes/thread/2c84c914-8524-481c-ba51-2b6a2e698980

    saludos


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina

    • Marcado como respuesta Eder CostaOwner martes, 13 de noviembre de 2012 12:46
    martes, 23 de octubre de 2012 0:06
  • Gracias los dos,

    Me sirvieron mucho sus respuestas...

    pero he tenido unos problemas en otras PC´s con Windows XP, con este mensaje "WMI data no encontrado".

    Saludos, Limberg.

    lunes, 29 de octubre de 2012 12:45