as far as I know strings (REG_SZ) created in the windows registry must be terminated with a 0-Byte.
But what happens if you want to create programatically a registry value with no content?
a) always terminate with 0-Byte (doesn’t matter if the registry value has content or not)
b) terminate only with 0-Byte if there is a content
Thanks!
You must always terminate the value with a null character. If there is no content, then the value will be that one null character and nothing else.
Note that a character is either one or two bytes long, depending on whether you are using the ANSI or Unicode APIs.
Update: The documentation for
RegSetValueExstates regarding its last parameter:The registry value types reference also says:
Now all this is not as clear as it could be, but it is well known that a null terminator in Unicode strings is actually two bytes (as is every other Unicode character in the BMP).