Quantcast
Channel: Obtener número de serie
Viewing all articles
Browse latest Browse all 4

Obtener número de serie

$
0
0

Hola, una consulta como puedo obtener el número de serie del disco duro y cada vez que formatee el disco me de el mismo número de serie, he encontrado este código pero me da error

Option Strict On
Option Explicit On 

Imports System.Management

Class DriveInfoApp

  <STAThread()> _
  Shared Sub Main()

    Dim drives As New ArrayList

    Dim query As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")

    For Each wmiDrive As ManagementObject In query.Get()
      Dim info As New DriveInfo
      info.Model = wmiDrive("Model").ToString()
      info.Type = wmiDrive("InterfaceType").ToString()
      drives.Add(info)
    Next

    query = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")

    Dim i As Integer = 0
    For Each wmiDrive As ManagementObject In query.Get()
      ' Get the hard drive from collection using index.
     Dim info As DriveInfo = CType(drives(i), DriveInfo)=> El indice esta fuera del intervalo.Debe ser un valor no negativo e inferior al tamaño de la colecciòn 
      ' Get the hardware serial number.
      If wmiDrive("SerialNumber") Is Nothing Then
        info.SerialNumber = "None"
      Else
        info.SerialNumber = wmiDrive("SerialNumber").ToString()
      End If
      i += 1
    Next

    ' Display available hard drives.
    For Each info As DriveInfo In drives
      Console.WriteLine("Model" + vbTab + vbTab + ": " + info.Model)
      Console.WriteLine("Type" + vbTab + vbTab + ": " + info.Type)
      Console.WriteLine("Serial No." + vbTab + ": " + info.SerialNumber)
      Console.WriteLine()
    Next

    Console.WriteLine("Press [Enter] to exit...")
    Console.ReadLine()

  End Sub

End Class

Class DriveInfo

  Private _model As String
  Private _type As String
  Private _serialNumber As String

  Public Property Model() As String
    Get
      Return _model
    End Get
    Set(ByVal Value As String)
      _model = Value
    End Set
  End Property

  Public Property Type() As String
    Get
      Return _type
    End Get
    Set(ByVal Value As String)
      _type = Value
    End Set
  End Property

  Public Property SerialNumber() As String
    Get
      Return _serialNumber
    End Get
    Set(ByVal Value As String)
      _serialNumber = Value
    End Set
  End Property

End Class


Pedro Avila



Viewing all articles
Browse latest Browse all 4

Trending Articles


FORECLOSURE OF REAL ESTATE MORTGAGE


HOY PANGIT, MAGBAYAD KA!


Girasoles para colorear


Presence Quotes – Positive Quotes


Love Quotes Tagalog


Long Distance Relationship Tagalog Love Quotes


“BAHAY KUBO HUGOT”


Re:Mutton Pies (lleechef)


Ka longiing longsem kaba skhem bad kaba khlain ka pynlong kein ia ka...


EASY COME, EASY GO


UPDATE SC IDOL: TWO BECOME ONE


Pokemon para colorear


Sapos para colorear


tagalog love Quotes – Tiwala Quotes


OFW quotes : Pinoy Tagalog Quotes


Tropa Quotes


“Mali man na ikaw ay ibigin ko, akoy iibig padin sayo”


RE: Mutton Pies (frankie241)


Vimeo 10.7.0 by Vimeo.com, Inc.


Vimeo 10.7.1 by Vimeo.com, Inc.



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>