You are mixing Unicode and ANSI:
With ANSI builds, you are assigning Unicode strings to
char*
for your
val
and
a
variables.
With Unicode builds, you are passing an ANSI string to
RegOpenKeyEx()
.
With ANSI builds, you are passing Unicode strings for value name and value to
RegSetValueEx()
.
With Unicode builds, the
RegSetValueEx()
cbData
parameter is wrong (the total length must be multiplied with sizeof(WHACR)).
Solution:
Use Unicode setting dependend macros and functions:
LPTSTR val=_T("12as3d12");
LPTSTR a=_T("zzz");
RegOpenKeyEx(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run)",
RegSetValueEx(key, a, 0, REG_SZ,(LPBYTE)val, (DWORD)(_tcslen(val)+1) * sizeof(TCHAR));