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.