_TCHAR pointer to the function.
void foo(_TCHAR* somestring) where somestring is globally declared TCHAR [200], then I call
RegSetValueEx(..., REG_SZ, (BYTE*)somestring, sizeof(somestring)); And only the first character is written.
_TCHAR pointer to the function.
void foo(_TCHAR* somestring) where somestring is globally declared TCHAR [200], then I call
RegSetValueEx(..., REG_SZ, (BYTE*)somestring, sizeof(somestring)); And only the first character is written.
If somestring global , then it does not need to be passed to a function - it is visible and so, because it is global :) And then - if it is visible as TCHAR[200] - the sizeof(somestring) expression sizeof(somestring) will be the size of this array.
But when you pass it to the function as void foo(_TCHAR* somestring) , the global variable becomes hidden, and under the name somestring in the body of the function there is already a completely different variable - the local pointer argument. And for it, sizeof(somestring) is not an array size, but a pointer, with all the ensuing consequences.
Pass also the length for writing to the registry to the foo function.
RegSetValueEx ? Another question (but, judging by the code, it’s not him) is about the use of Unicode, whether everything is true from this point of view. - HarrySource: https://ru.stackoverflow.com/questions/819499/
All Articles
char* str = "Helllo"; cout << (*str) += 1 << endl; // echar* str = "Helllo"; cout << (*str) += 1 << endl; // echar* str = "Helllo"; cout << (*str) += 1 << endl; // e- Evgeny Ivanovsomestringis just a parameter of the_TCHAR*typefoofunction ??? - AnT