c# - Read string value from registry but the result contains some weird characters -
i'm reading string values registry using registry.getvalue, result seems have 'invisible' characters don't see registry editor.
for example, registry.getvalue returns "london\0j" expected "london", , in registry editor can see value "london" , there doesn't seem @ end of string. if export key .reg file shows "london". don't have permission write registry can't test importing .reg file.
apply string.trim result doesn't work either.
what "\0j"?
edit: code read key value
    var registryvalue =         registry.getvalue(@"hkey_local_machine\system\\currentcontrolset\\services\\netlogon\\parameters",             "dynamicsitename", string.empty); the exported .reg file:
windows registry editor version 5.00  [hkey_local_machine\system\currentcontrolset\services\netlogon\parameters] "dynamicsitename"="london" 
as can see in reference source getvalue uses regqueryvalueex read complete value registry.
then data converted target c# type according registry type returned (as output parameter) regqueryvalueex.
so see written registry. don't see \0j in regedit tool implemented using zero-terminated strings. regedit "thinks" string ends @ \0 , not display it.
but since getvalue reads really there, you're output correct. c# not use \0 string termination character.
of course can't tell wrote data registry , if valid or not. (it used sort of weird hidden information app verify value written app)
Comments
Post a Comment