In a 64-bit Windows operating system, a 64-bit Windows operating system uses a redirection mechanism in order to be compatible with 32-bit programs. The goal is to allow 32-bit programs to operate in 64-bit operating systems not only to manipulate key file folders and critical registry but also to avoid conflicts with 64-bit programs
For more information, see the redirection mechanism of 32-bit programs running under 64-bit systems
Here is a case for obtaining the operating system installation key key:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingMicrosoft.Win32;namespacereadproductkey{classProgram {Static voidMain (string[] args) { stringBackupproductkeydefault; RegistryKey Localkey=NULL; Try {
Determine the operating system version (64-bit \ 32-bit) to open the registry key Localkey= Registrykey.openbasekey (Registryhive.localmachine, Environment.is64bitoperatingsystem?)RegistryView.Registry64:RegistryView.Registry32);
Get registry key value Backupproductkeydefault= Localkey.opensubkey (@"SOFTWARE\Microsoft\Windows Nt\currentversion\softwareprotectionplatform"). GetValue ("Backupproductkeydefault",""). ToString (); Console.WriteLine (Backupproductkeydefault); Console.ReadLine (); } Catch(Exception ex) {} }}}
Program execution Interface:
Note: If you open a registry key with Registryview.registry32 and compile it as a 32-bit version of the program, you cannot get the System key registry keys
Original address: http://www.cnblogs.com/iamlucky/p/5998510.html
C # 32-bit programs registry operation under 64-bit systems