Here's a slightly modified version packaged in a function.
Code:

Break ON
$=SetOption("WrapAtEOL","ON")

function get_product_key ($sProductID)
Dim $aiKeyChars[24]
Dim $ilByte
Dim $i
Dim $bProductKey[15]
Dim $sCDKey

$aiKeyChars = 'B','C','D','F','G','H','J','K','M','P','Q','R','T','V','W','X','Y','2','3','4','6','7','8','9'

for $i = 0 to 14
$bProductKey[$i] = val("&"+substr($sProductID,$i*2+105,2))
next

$sCDKey = ""
For $ilByte = 24 To 0 Step -1
$nCur = 0

For $i=14 To 0 Step -1
$nCur = $nCur * 256 | $bProductKey[$i]
$bProductKey[$i] = Int($nCur / 24)
$nCur = $nCur Mod 24
Next
$sCDKey = $aiKeyChars[$nCur] + $sCDKey
If $ilByte Mod 5 = 0 And $ilByte <> 0 $sCDKey = "-" + $sCDKey EndIf
Next
$get_product_key = $sCDKey
endfunction

$dpi=ReadValue("HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\Windows NT\CurrentVersion","DigitalProductID")
$key = get_product_key($dpi)
? "Windows Product Key: " + $key

? "Press any key..."
get $



Does anyone have any suggestions on the most appropriate name for the function?

Regards,
Christian.


Edited by CJPinder (2005-09-08 05:39 PM)