我有这个功能从注册表中解码DigitalProductId,相同的代码遍布互联网但是没有在我的Windows Server 2012中返回预期的产品密钥,我有产品密钥,这个代码应该找到它对我来说,它会返回一个不同的键:
Shared Function DecodeProductKey(digitalProductId As Byte()) As String
Const keyStartIndex As Integer = 52
Const keyEndIndex As Integer = keyStartIndex + 15
Dim digits As Char() = New Char() {"B"c, "C"c, "D"c, "F"c, "G"c, "H"c,
"J"c, "K"c, "M"c, "P"c, "Q"c, "R"c,
"T"c, "V"c, "W"c, "X"c, "Y"c, "2"c,
"3"c, "4"c, "6"c, "7"c, "8"c, "9"c}
Const decodeLength As Integer = 29
Const decodeStringLength As Integer = 15
Dim decodedChars As Char() = New Char(decodeLength - 1) {}
Dim hexPid As New ArrayList()
For i As Integer = keyStartIndex To keyEndIndex
hexPid.Add(digitalProductId(i))
Next
For i As Integer = decodeLength - 1 To 0 Step -1
If (i + 1) Mod 6 = 0 Then
decodedChars(i) = "-"c
Else
Dim digitMapIndex As Integer = 0
For j As Integer = decodeStringLength - 1 To 0 Step -1
Dim byteValue As Integer = (digitMapIndex << 8) Or CByte(hexPid(j))
hexPid(j) = CByte(byteValue \ 24)
digitMapIndex = byteValue Mod 24
decodedChars(i) = digits(digitMapIndex)
Next
End If
Next
Return New String(decodedChars)
End Function
Windows Server 2012是否有新的解码方法? 有没有人在这个操作系统中使用此代码?
编辑: 我从注册表中获取了DigitalProductId。应该有什么价值的产品密钥? Registry values