已解决
以下代码用来读取 Windows 系统序列号,3.2.12 及以前版本读取正确,以后的版本(包括最新的 3.3)就不正确了,郁闷。。。Dim $Setkey = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductID")
$Key = DecodeProductKey($Setkey)
If $Key<>"" Then
MsgBox(64,"SN",$Key)
EndIf
Func DecodeProductKey($BinaryDPID) ;读取序列号
Local $bKey
Local $sKey
Local $Digits
Local $Value = 0
Local $hi = 0
Local $n = 0
Local $i = 0
Local $dlen = 29
Local $slen = 15
Local $Result
$Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789", "")
$BinaryDPID = StringMid($BinaryDPID, 105, 30)
For $i = 1 To 29 Step 2
$bKey = Dec(StringMid($BinaryDPID, $i, 2))
Next
For $i = $dlen - 1 To 0 Step - 1
If Mod(($i + 1), 6) = 0 Then
$sKey[$i] = "-"
Else
$hi = 0
For $n = $slen - 1 To 0 Step - 1
$Value = BitOR(BitShift($hi, -8), $bKey[$n])
$bKey[$n] = Int($Value / 24)
$hi = Mod($Value, 24)
Next
$sKey[$i] = $Digits[$hi + 1]
EndIf
Next
For $i = 0 To 28
$Result = $Result & $sKey[$i]
Next
EndFunc
[ 本帖最后由 新手上路 于 2009-1-18 21:12 编辑 ] 新版用以下这个代码,在XP SP3 AU3 3.3.0.0下测试正确。
$key = RegRead("HKLM\SOFTWARE\MICROSOFT\Windows NT\CurrentVersion","DigitalProductId")
MsgBox(0,0,GetXPKey($key))
Func GetXPKey($binaryDPID)
Local $bKey
Local $sKey
Local $Digits
Local $Value = 0
Local $hi = 0
local $n = 0
Local $i = 0
Local $dlen = 29
Local $slen = 15
Local $Result
$Digits = StringSplit("BCDFGHJKMPQRTVWXY2346789","")
$binaryDPID = stringmid($binaryDPID,107,30)
For $i = 1 to 29 step 2
$bKey = dec(stringmid($binaryDPID,$i,2))
next
For $i = $dlen -1 To 0 Step -1
If Mod(($i + 1), 6) = 0 Then
$sKey[$i] = "-"
Else
$hi = 0
For $n = $slen -1 To 0 Step -1
$Value = Bitor(bitshift($hi ,- 8) , $bKey[$n])
$bKey[$n] = int($Value / 24)
$hi = mod($Value , 24)
Next
$sKey[$i] = $Digits[$hi +1]
EndIf
Next
For $i = 0 To 28
$Result = $Result & $sKey[$i]
Next
Return $Result
EndFunc
感谢。:face (38):
页:
[1]