//Portage en C# de l'application KeyFinder : http://magicaljellybean.com/keyfinder/
Microsoft.Win32.RegistryKey masterKey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey ("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"); byte [] HexSrc = (System.Byte [])masterKey.GetValue ("DigitalProductId"); masterKey.Close (); int StartOffset = 51; int EndOffset = StartOffset + 15; char [] Digits = {'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'M', 'P', 'Q', 'R', 'T', 'V', 'W', 'X', 'Y', '2', '3', '4', '6', '7', '8', '9'}; const int DecodedLen = 29; const int EncodedLen = 15; uint [] HexDigitalPID = new uint [DecodedLen]; char [] Des = new char [30]; int i; int N; uint HN; uint Value; for (i = StartOffset ; i <= EndOffset ; i++) { HexDigitalPID [i - StartOffset] = HexSrc [i]; } for (i = DecodedLen - 1 ; i >= 0 ; i--) { if ((i + 1) % 6 == 0) { Des [i] = '-'; } else { HN = 0; for (N = EncodedLen ; N > 0 ; N--) { Value = (HN << 8) | HexDigitalPID [N]; HexDigitalPID [N] = Value / 24; HN = Value % 24; } Des [i] = Digits [HN]; } Des [DecodedLen] = Convert.ToChar (0); } foreach (char c in Des) { Console.Write (c); }