Why does the Win32 API fail to read a registry value whose name contains a null byte?
The Win32 API treats the null byte (0x0000) as the standard C string terminator. When a function like `RegQueryValueEx` receives a name that starts with or contains \0, it truncates the name at the first null byte, leading to a lookup failure. This behavior is confirmed by the article, which shows that reading `\0test1` returns `ERROR_FILE_NOT_FOUND`. Native API functions avoid this by requiring an explicit length parameter.
Win32 API failureERROR_FILE_NOT_FOUNDnull terminationRegQueryValueExstring truncation