C # 32-bit programs registry operation under 64-bit systems

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.