none
Obtener Numero de Serie de Discos Sata e IDE RRS feed

  • Pregunta

  • Hola.

    quisiera obtener el numero de serie fisico del disco duro ya sea IDE o Sata, la HDSN solo sirve para IDE pero requiero que sirva para ambos (IDE y Sata).

    Gracias por su amable ayuda


    • Editado Jesus Matiz jueves, 26 de febrero de 2015 5:11
    jueves, 26 de febrero de 2015 5:05

Respuestas

  • Hola,

    Quizá te sirva lo siguiente, el código está escrito en c#

    using System;
    using System.Management;
     
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                try
                {
                    ManagementObjectSearcher searcher =
                        new ManagementObjectSearcher("root\\CIMV2",
                        "SELECT * FROM Win32_DiskDrive");
     
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        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)
                {
                    Console.WriteLine("Error: " + e.Message);
                }
                finally
                {
                    Console.ReadLine();
                }
            }
        }
    }

    Si la solución propuesta atendió su consulta no olvide marcarla como respuesta.

    Willams Morales
    Arequipa - PERÚ

    • Marcado como respuesta Jesus Matiz sábado, 28 de febrero de 2015 0:21
    jueves, 26 de febrero de 2015 5:12

Todas las respuestas

  • Hola,

    Quizá te sirva lo siguiente, el código está escrito en c#

    using System;
    using System.Management;
     
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                try
                {
                    ManagementObjectSearcher searcher =
                        new ManagementObjectSearcher("root\\CIMV2",
                        "SELECT * FROM Win32_DiskDrive");
     
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        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)
                {
                    Console.WriteLine("Error: " + e.Message);
                }
                finally
                {
                    Console.ReadLine();
                }
            }
        }
    }

    Si la solución propuesta atendió su consulta no olvide marcarla como respuesta.

    Willams Morales
    Arequipa - PERÚ

    • Marcado como respuesta Jesus Matiz sábado, 28 de febrero de 2015 0:21
    jueves, 26 de febrero de 2015 5:12
  • hola

    pero hay miles de preguntas sobre este mismo tema solo es cuestion de buscar en poco

     Serial del disco duro

     leer numero serial disco duro en visual studio .net

    -----

    es mas la respuesta de William se obtiene de una previa en el foro

     numero de serie fisico de disco duro

    saludos


    Leandro Tuttini

    Blog
    MVP Profile
    Buenos Aires
    Argentina

    jueves, 26 de febrero de 2015 6:01