Attribute VB_Name = "gethwid"

Private Declare Function GetVolumeSerialNumber _
                Lib "kernel32.dll" _
                Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, _
                                               ByVal lpVolumeNameBuffer As String, _
                                               ByVal nVolumeNameSize As Long, _
                                               lpVolumeSerialNumber As Long, _
                                               lpMaximumComponentLength As Long, _
                                               lpFileSystemFlags As Long, _
                                               ByVal lpFileSystemNameBuffer As String, _
                                               ByVal nFileSystemNameSize As Long) As Long

Global paso         As Integer

Global hhii         As String

Global WebsiteURL   As String

Global Versionurl   As String

Global HwidUrl      As String

Global NewUpdateURL As String

Global pass2        As String

Global datosupdate  As String

Public Function HardwareID() As String
    Dim sVolLabel    As String, sSerial As Long, sName As String
    Dim objCPUItem   As Object, objCPU As Object
    Dim objBaseBoard As Object, objBoard As Object

    If GetVolumeSerialNumber(Left(Environ("windir"), 3), sVolLabel, 0, sSerial, 0, 0, sName, 0) Then
        HardwareID = Hex(sSerial)
    Else
        HardwareID = "00"

    End If

    Set objCPUItem = GetObject("winmgmts:").InstancesOf("Win32_Processor")

    If err.Number = 0 Then

        For Each objCPU In objCPUItem

            HardwareID = HardwareID & objCPU.MaxClockSpeed
            HardwareID = HardwareID & objCPU.ProcessorId
        Next
        Set objCPUItem = Nothing

    End If

    Set objBaseBoard = GetObject("WinMgmts:").InstancesOf("Win32_BaseBoard")

    For Each objBoard In objBaseBoard

        HardwareID = HardwareID & objBoard.SerialNumber
        Exit For
    Next

    For i = 1 To Len(HardwareID)

        If IsNumeric(Mid(HardwareID, i, 1)) = True Then
            sTmp = sTmp + Mid(HardwareID, i, 1)

        End If

    Next

    For i = 1 To Len(sTmp)
        sResult = sResult & Mid(sTmp, i, 1) Mod 12
    Next
    HardwareID = StrReverse(sResult)

End Function
