. Net 2.0 Original read Registry

Source: Internet
Author: User

In. Net 1. x, when the GetValue method of the Microsoft. Win32.RegistryKey class is used to read the registry data, the data is actually processed;

For example, the original value of a string is % SystemRoot % \ System32 \ IoLogMsg. dll, but the data obtained using the GetValue method is C: \ WINDOWS \ System32 \ IoLogMsg. dll.

That is to say, when reading strings in the Registry, the system will expand the environment variables for you on its own initiative.

This does save the trouble of calling the Environment. ExpandEnvironmentVariables method, but in turn, we are helpless when we want to copy a registry string intact.

In. Net2.0, we were pleasantly surprised to find that the Microsoft. Win32.RegistryKey class had a small change, that is, its GetValue method added a new overload:

Public Object GetValue (
String name,
Object defaultValue,
RegistryValueOptions options
)

The third parameter of this method is an enumeration. Currently, only one useful value is DoNotExpandEnvironmentNames.
Specify this value. The GetValue result is the unexpanded data.

 

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.