似水年华 2008-1-17 12:05 PM
Windows XP/2003 序列号更换工具 源码
[code]
#include <GUIConstants.au3>
#include <Constants.au3>
_wmiset()
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
;Global $colComputers
$colComputers = $objWMIService.ExecQuery("Select * from win32_WindowsProductActivation")
$hgui = GUICreate("Windows XP/2003 序列号更换工具", 300, 150)
GuiSetIcon("shell32.dll",162, $hgui)
Dim $Setkey = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "DigitalProductID")
GUICtrlCreateLabel("系统序列号:更换序号请按照以下格式输入", 20, 10, 300, 20)
GUICtrlSetColor(-1,0xff0000)
$Key = GUICtrlCreateInput("",20, 30,230, 25)
GUICtrlSetData($key, DecodeProductKey($Setkey))
$readbutton = GUICtrlCreateButton("修改", 20, 80, 100, 25)
$exitbutton = GUICtrlCreateButton("退出", 150, 80, 100, 25)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $readbutton
$readkey = GUICtrlRead($Key)
If $readkey = "" then
MsgBox(16,"错误","你确定你输入的序列号没错吗?")
Else
$Setkey=StringReplace($readkey,"-","")
;MsgBox(0,"sdlkfj",$Setkey)
;for $obj In $colComputers
;$Obj.SetProductKey ($Setkey)
if @error = 0 then
MsgBox(64,"恭喜!!!","您的 Windows CD-KEY 修改成功。请检查系统属性。")
Endif
if @error <> 0 then
MsgBox(16,"失败","修改失败!请检查输入的 CD-KEY 是否与当前 Windows 版本相匹配。")
Endif
;Next
Endif
Case $msg = $GUI_EVENT_CLOSE Or $msg = $exitbutton
Exit
EndSelect
WEnd
Func DecodeProductKey($BinaryDPID)
Local $bKey[15]
Local $sKey[29]
Local $Digits[24]
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[Int($i / 2) ] = 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
Func _wmiset()
;制作:叁恨居士
;功能:判断系统是否存在WMI服务,没有便退出。如果没有运行,便将WMI服务设置启动类型为自动并运行它。
$foo = Run(@ComSpec & " /c sc query winmgmt", @SystemDir, @SW_HIDE, $STDOUT_CHILD)
$lines = ""
While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
$lines &= $line
Wend
$lines = StringSplit($lines,@CRLF,1)
For $x = 1 To $lines[0]
If StringInStr($lines[$x], "1060") Then
MsgBox(32,"错误","本软件运行所需的服务不存在")
ExitLoop
Exit
ElseIf StringInStr($lines[$x], "STOPPED") Then
RunWait(@ComSpec & ' /c sc config winmgmt start= auto', @SystemDir, @SW_HIDE)
RunWait(@ComSpec & ' /c sc start winmgmt', @SystemDir, @SW_HIDE)
ExitLoop
EndIf
Next
EndFunc[/code]
redapple 2008-11-6 12:57 PM
这个算号器不对,有错误。