Jump to content

Numero de Serie do Disco


pmsmc
 Share

Recommended Posts

Caro Weasel,

essa pesquisa já tinha feito, só que em todo o código de .NET, aparece um ManagmentObject que mesmo com os Imports dos Namespaces correctos nunca funciona.

Imports System
Imports System.IO
Imports System.Management
Imports System.Windows.Forms
Public Class gethdd
    Private Sub CheckHDSN()
        Try
            Dim Searcher_P As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_PhysicalMedia")
            For Each queryObj As ManagementObject In Searcher_P.Get()
                If queryObj("SerialNumber").ToString.Trim = "Y2S0RKFE" Then
                    Exit Sub
                End If
            Next
        Catch ex As Exception
            MessageBox.Show("An error occurred while querying for WMI data: Win32_PhysicalMedia " & ex.Message)
        End Try
        '
        Try
            Dim Searcher_L As New ManagementObjectSearcher("root\CIMV2", "SELECT * FROM Win32_LogicalDisk WHERE DeviceID = 'C:'")
            For Each queryObj As ManagementObject In Searcher_L.Get()
                If queryObj("VolumeSerialNumber").ToString.Trim = "226C1A0B" Then
                    Exit Sub
                End If
            Next
        Catch ex As Exception
            MessageBox.Show("An error occurred while querying for WMI data: VolumeSerialNumber " & ex.Message)
        End Try
        MessageBox.Show("Hard Disk Serial Number Not Matching !!!" & vbNewLine & vbNewLine & "Asta La Vista Baby !!!")
        End
    End Sub
End Class
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.