RoloTomasi
Advanced Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Код: <html> <!--******************************************************************** '* '* File: xpkey.hta '* Created: 2005.12.08 '* Version: 1.0 '* '********************************************************************--> <title>xpkey</title> <HTA:APPLICATION ID="xpkey" APPLICATIONNAME="xpkey" SCROLL="no" maximizeButton="no" version="1.0" SINGLEINSTANCE="yes" WINDOWSTATE="normal" SCROLLFLAT="yes" INNERBORDER="no" ICON=""/> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <style> body { background-color: buttonface; font-family: Helvetica; font-size: 8pt; margin-top: 10px; margin-left: 10px; margin-right: 10px; margin-bottom: 10px; } </style> <script language="vbscript"> Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion" strValueName = "DigitalProductId" oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath, strValueName,strValue function testVb document.getElementById("vbkey").value = vbXPKeyFromProductId(strValue) end function function vbXPKeyFromProductId (bKey) dim KeyBase KeyBase = Array ("B", "C", "D", "F", "G", "H", "J","K", "M", "P", "Q", "R", "T", "V", "W", "X", "Y", "2", "3", "4", "6", "7", "8", "9") dLen = 29 sLen = 15 dim Dst(29) StartOffset = &H34 EndOffset = &H34 + 15 dim Src(15) for i = StartOffset to EndOffset Src(i-StartOffset) = bKey(i) next for i = dLen - 1 to 0 step -1 if ((i + 1) mod 6) = 0 then Dst(i) = "-" else HN = 0 for n = sLen - 1 to 0 step -1 Value = (HN * 256) Or Fix(Src(n)) Src(n) = Value / 24 HN = Value Mod 24 next Dst(i) = KeyBase(HN) end if next str = "" for i = 0 to dLen - 1 str = str + Dst(i) next vbXPKeyFromProductId = str end function </script> <script language="jscript"> function window.onload() { self.focus(); self.resizeTo(400,220); } var strComputer = "."; var HKEY_LOCAL_MACHINE = 0x80000002 var HKEY_CURRENT_USER = 0x80000001 var WshShell = new ActiveXObject("WScript.Shell"); var bTempKey = VBArray(WshShell.RegRead("HKLM\\SOFTWARE\\MICROSOFT\\Windows NT\\CurrentVersion\\DigitalProductId")); var bKey = new Array bKey = bTempKey.toArray(); function testJs() { document.getElementById("jskey").value = jsXPKeyFromProductId(bKey); } function jsXPKeyFromProductId(bKey) { // (c) FreemanRU. ru-board var KeyBase = new Array('B', 'C', 'D', 'F', 'G', 'H', 'J','K', 'M', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9'); var dLen = 29; var sLen = 15; var Dst = new Array(dLen); var StartOffset = 0x34; var EndOffset = 0x34 + 15 var Src = new Array(15); for (var i = StartOffset; i<=EndOffset; i++) { Src[i-StartOffset] = bKey[i] } for (var i = dLen - 1; i>=0; i--) { if (((i + 1) % 6) == 0) { Dst[i] = '-'; } else { var HN = 0; for (var n = sLen - 1; n>=0; n--) { var Value = (HN << 8) | Src[n]; Src[n] = Value / 24; HN = Value % 24; } Dst[i] = KeyBase[HN]; } } var str = ""; for (i = 0; i<=dLen-1; i++) { str += Dst[i]; } return str; } function changeKey() { var prod_key = document.getElementById("newkey").value; var re = new RegExp("[0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z]-" + "[0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z]-" + "[0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z]-" + "[0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z]-" + "[0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z][0-9,A-Z]"); if(!re.test(prod_key)) { alert("Not valid Product Key!"); return; } prod_key = prod_key.replace(/-/,"") var objProdActiv = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf ("win32_WindowsProductActivation"); var vret = 0; for(var _enum=new Enumerator(objProdActiv);!_enum.atEnd();_enum.moveNext()) { var objItem = _enum.item(); try { vret = objItem.SetProductKey(prod_key); alert("Your product key has been successfully updated."); } catch(e) { alert("An error has occurred. This was probably caused by the keying of an invalid number. Please check it and try again."); } } } </script> </head> <body> <table> <td> <hr> <input type="button" onclick="testVb()" title="" value="TEST VB" style="font-family:Verdana;font-size:12px;width:90px;"> <input style="font-family:Verdana;font-size:12px;" size="40" type="text" id="vbkey" /> <br /> <input type="button" onclick="testJs()" title="" value="TEST JS" style="font-family:Verdana;font-size:12px;width:90px;"> <input style="font-family:Verdana;font-size:12px;" size="40" type="text" id="jskey" /> <br/><hr> <input type="button" onclick="changeKey()" title="" value="Change Key" style="font-family:Verdana;font-size:12px;width:90px;"> <input style="font-family:Verdana;font-size:12px;" size="40" type="text" id="newkey" /> <br /> </td> </tr> </table> </body> </html> | |