Articles I've written for customers on IT issues.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
622 B

5 years ago
  1. Set WshShell = CreateObject("WScript.Shell")
  2. MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId"))
  3. Function ConvertToKey(Key)
  4. Const KeyOffset = 52
  5. i = 28
  6. Chars = "BCDFGHJKMPQRTVWXY2346789"
  7. Do
  8. Cur = 0
  9. x = 14
  10. Do
  11. Cur = Cur * 256
  12. Cur = Key(x + KeyOffset) + Cur
  13. Key(x + KeyOffset) = (Cur \ 24) And 255
  14. Cur = Cur Mod 24
  15. x = x -1
  16. Loop While x >= 0
  17. i = i -1
  18. KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput
  19. If (((29 - i) Mod 6) = 0) And (i <> -1) Then
  20. i = i -1
  21. KeyOutput = "-" & KeyOutput
  22. End If
  23. Loop While i >= 0
  24. ConvertToKey = KeyOutput
  25. End Function