In .Net 1.x, when using the GetValue method of the Microsoft.Win32.RegistryKey class to read registry data, the data is actually "processed";
For example, the original value of a certain string data is
%SystemRoot%System32IoLogMsg.dll
But the data obtained using the GetValue method is
C:WINDOWSSystem32IoLogMsg.dll
In other words, when reading the string in the registry, the system will expand the environment variables for you on its own initiative.
This does save us the trouble of calling the Environment.ExpandEnvironmentVariables method, but conversely, when we want to copy a registry string intact, we are helpless.
In .Net2.0, we were pleasantly surprised to find that the Microsoft.Win32.RegistryKey class has a small change, that is, a new overload has been added to its GetValue method:
public Object GetValue (
string name,
Object defaultValue,
RegistryValueOptions options
) The third parameter of this method is an enumeration, and currently the only useful value is DoNotExpandEnvironmentNames.
Specify this value, and the result obtained by GetValue is the data that has not been expanded.