So I want to add a string to registry, since the registry strings are to written NULL terminated my string contains a null char in various places.
This is what my string looks like.
char names[550] = "1DFA-3327-*\01DFA-3527-*\001DFA-E527-*\00951-1500-
I convert this to whcar_t
string like so.
wchar_t names_w[1000];
size_t charsConverted = 0;
mbstowcs_s(&charsConverted, names_w, names, SIZE);
RegSetValueEx(*pKeyHandle, valueName, 0, REG_MULTI_SZ, (LPBYTE)names_w, size);
The registry entry should be
1DFA-3327-*
1DFA-3527-*
1DFA-E527-*
0951-1500-*
0951-0004-*
0951-160D-*
But this is the registry entry now,
1DFA-3327-*
<a box here>DFA-3527-*
<a box here>DFA-E527-*
951-1500-*
951-0004-*
951-160D-*
So it eats up the 0
in 0951
also eats up the 1
in 1DFA
What I have tried:
1> I tried changing the string to
char names[550] = "1DFA-3327-*\0\01DFA-3527-*\0\001DFA-E527-*\0\00951-1500-
^ ^ Two nulls
2> I tried different conversion.
for(int i; i < SIZE; i++)
names_w[i] = (wchar_t)names[i];