WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Get Original Windows CD Key


#DefineFunction Dec2Hex(Dec)
IsZero=@TRUE
str="0123456789ABCDEF"
hex=""

For x=7 To 0 By -1
nibble= (dec >> (x*4)) & 15
If nibble==0 && IsZero==@TRUE Then Continue
IsZero=@FALSE
hex=StrCat(hex,StrSub(str,nibble+1,1))
Next
Return(hex)
#EndFunction

#DefineFunction Hex2Dec(hex)
str="0123456789ABCDEF"
hex=StrTrim(StrUpper(hex))
hexlen=StrLen(hex)
dec=0
For x=1 To hexlen
dec=(dec*16) + StrIndex(str,StrSub(hex,x,1),0,@FWDSCAN) -1
Next
Return(dec)
#EndFunction

reghandle=RegOpenKeyEx(@REGMACHINE,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","READ",0,0)
tmp=RegQueryBin(reghandle,"[DigitalProductId]")
RegCloseKey(reghandle)
HexBuf=Arrayize(tmp," ")
lbound=0
ubound=ArrInfo(HexBuf,1) -1
StartOffset=52
EndOffset=67
Digits=ArrDimension(24)
Digits [0] = "B"
Digits [1] = "C"
Digits [2] = "D"
Digits [3] = "F"
Digits [4] = "G"
Digits [5] = "H"
Digits [6] = "J"
Digits [7] = "K"
Digits [8] = "M"
Digits [9] = "P"
Digits [10] = "Q"
Digits [11] = "R"
Digits [12] = "T"
Digits [13] = "V"
Digits [14] = "W"
Digits [15] = "X"
Digits [16] = "Y"
Digits [17] = "2"
Digits [18] = "3"
Digits [19] = "4"
Digits [20] = "6"
Digits [21] = "7"
Digits [22] = "8"
Digits [23] = "9"

dLen=29
sLen=15

HexDigitalPID=ArrDimension(16) ;15
Des=ArrDimension(30)
tmp2=""
For i=StartOffset To EndOffset
tempxyz= HexBuf[i] ;<<<<<<<<<<<<<
HexDigitalPID [i-StartOffset] = tempxyz
tmp2=tmp2 : " " : Hex2Dec (HexDigitalPID[i-StartOffset] )
Next

KEYSTRING=""
For i=dLen-1 To 0 By -1
If ((i + 1) mod 6) == 0
Des [i] = "-"
KEYSTRING =KEYSTRING : "-"
Else
HN = 0
For N = (sLen-1) To 0 By -1
Value = ( (HN *2**8 ) | Hex2Dec(HexDigitalPID [N]))
HexDigitalPID [N] = Dec2Hex(Value / 24 ) ;Value \ 24
HN = (Value mod 24)

Next
Des[i] = Digits[HN]
KEYSTRING =KEYSTRING : Digits[HN]
EndIf
Next

KeyString2 = ""
For xx = 29 To 1 By -1
ThisLetter = StrSub(KeyString, xx, 1)
KeyString2 = StrCat(KeyString2,ThisLetter)
Next xx

Message("Original Windows CD Key was:",KeyString2)
Exit




Article ID:   W17221
File Created: 2007:07:03:14:28:52
Last Updated: 2007:07:03:14:28:52