Does the Windows API RegGetValue require a direct descendant for it’s lpSubKey parameter?
Will this work?
RegGetValue(HKEY_LOCAL_MACHINE,
L"Software\\Microsoft\\Windows NT\\CurrentVersion", L"ProductName",
RRF_RT_REG_SZ, NULL, outdata, &outdata_size);
Edit: I had a leading slash \\ and Windows doesn’t like it! Also converted UTF-8 strings to UTF-16 wide strings (Windows-Style).
No, it does not.
You can specify a path just as you’ve shown. You also don’t need the leading path separator (
\\).But the code you’ve shown may or may not work. Not because it specifies a path to the string, but because you’re probably mixing Unicode and ANSI strings. From your user name (unixman), I assume that you’re relatively new to Windows programming, so it’s worth noting that Windows applications are entirely Unicode and have been for more than a decade. You should therefore always compile your code as Unicode and prefix string literals with
L(to indicate a wide, or Unicode, string).Likewise, make sure that
outdatais declared as an array ofwchar_t.