I recently encountered a problem with RegSetValueEx (from advapi32.dll). It looks like REG_SZ saved with this method in .Net 3.5 is not read correctly in .Net 4.5 with RegistryKey.GetValue (). Illustration below:
//
Call RegSetValueEx() to save base64 string value "ajG8s" to the registry
Call RegistryKey.GetValue() on that value returns "ajG8s"
//
Call RegSetValueEx() to save base64 string value "ajG8s" to the registry
Call RegistryKey.GetValue() on that value returns "ajG8s"
//
Call RegSetValueEx() to save base64 string value "ajG8s" to the registry (in .Net 3.5)
Call RegistryKey.GetValue() on that value returns "ajG8s\0\0\0\0\0\6\A\z./,'./Z?" (in .Net 4.5)
The code is 100% the same as the examples above - just switch .Net 4.5 version.
Initially, I thought that perhaps the line being written to the registry was not correctly terminated by zero - this is so. I also confirmed that this does not happen if I try to write a value using RegistryKey.SetValue () - it looks like it is calling RegSetValueEx (from advapi32.dll).
( 4.5) . , .
, ? !