If you like IronPython script for retrieving MS products' keys then you like IronRuby analog. Maybe...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Registry = Microsoft::Win32::Registry
def DecodeProductKey(digitalProductID)
map = ("BCDFGHJKMPQRTVWXY2346789").split('')
key = []
raw = []
i = 52
while i < 67:
raw.Add(digitalProductID[i])
i += 1
end
i = 28
while i >= 0
if (i + 1) % 6 == 0
key[i] = '-'
else
k = 0
j = 14
while j >= 0
k = (k * 256) ^ raw[j]
raw[j] = (k / 24)
k %= 24
key[i] = map[k]
j -= 1
end
end
i -= 1
end
return key.to_s
end
def GetProductKey(key, val = 'DigitalProductId')
reg = Registry.LocalMachine.OpenSubKey(key).GetValue(val)
puts DecodeProductKey(reg)
end
GetProductKey('SOFTWARE\Microsoft\Windows NT\CurrentVersion')
|
Tags: ironruby, productkey