Use. NET 4.0 + to operate the Registry in a 64-bit system. net4.0
I. 64-bit Registry
Take the startup Item in LocalMachine as an example:
The Registry of the 64-bit application is still located at: SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run
The 32-bit Application Registry is located at: SOFTWARE \ Wow6432Node \ Microsoft \ Windows \ CurrentVersion \ Run
2. How to operate the registry before. NET4.0 (excluding 4.0)
RegistryKey hklm = Registry. LocalMachine; RegistryKey run = hklm. OpenSubKey (@ "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run", true); // other operations
In the above Code, although "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run" is opened, it points to the location of the registry of the 32 application, namely:
"SOFTWARE \ Wow6432Node \ Microsoft \ Windows \ CurrentVersion \ Run", that is, the registry of a 64-bit application cannot be operated in a 64-bit system using the above method.
3. Use. NET4.0 + (including 4.0) to operate the registry of a 64-bit Application
RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); RegistryKey run = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
Iv. RegistryView Enumeration
Specifies the Registry view to be targeted on a 64-bit operating system.
| Default |
Default view. |
| Registry64 |
64-bit view. |
| Registry32 |
32-bit view. |
Note: If you request a 64-bit view on a 32-bit operating system, the keys returned are all in the 32-bit view.
5. MSDN related information
Https://msdn.microsoft.com/zh-cn/library/microsoft.win32.registrykey.openbasekey (v = vs.100). aspx
Https://msdn.microsoft.com/zh-cn/library/microsoft.win32.registryview (v = vs.100). aspx