Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Get windows product Key

$
0
0
Hi, i have this code for retrieving the windows product key of a machine that i got online.

Imports Microsoft.Win32
Module Module1
    Public strkey As String
    Public Function sGetXPKey() As String
        'Open the Registry Key and then get the value (byte array) from the SubKey
        Dim RegKey As RegistryKey = _
        Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows NT\CurrentVersion", False)
        Dim bytDPID() As Byte = RegKey.GetValue("DigitalProductID")
        'Transfer only the needed bytes into our Key Array
        ' Key starts at byte 52 and is 15 bytes long.
        Dim bytKey(14) As Byte '0-14 = 15 bytes
        Array.Copy(bytDPID, 52, bytKey, 0, 15)
        'Our "Array" of valid CD-Key characters
        Dim strChar As String = "BCDFGHJKMPQRTVWXY2346789"
        'Finally, our decoded CD-Key to be returned

        'How Microsoft encodes this to begin with, I'd love to know...
        'but here's how we decode the byte array into a string
        'containing the CD-KEY.
        For j As Integer = 0 To 24
            Dim nCur As Short = 0
            For i As Integer = 14 To 0 Step -1
                nCur = CShort(nCur * 256 Xor bytKey(i))
                bytKey(i) = CByte(Int(nCur / 24))
                nCur = CShort(nCur Mod 24)
            Next
            strKey = strChar.Substring(nCur, 1) & strKey
        Next
        'Finally, insert the dashes into the string.
        For i As Integer = 4 To 1 Step -1
            strKey = strKey.Insert(i * 5, "-")
        Next
        Return strKey
    End Function
End Module



The problem is, it's not working...? Not an error, nothing, just empty.
Shouldn't that work?

Thanks for anyone who helps.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



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