RegSetValueEx shows only the first character of a record

In the following code, RegSetValueEx writes only the first letter of my string. I tried resizing to everything I can think of, and I only get the first row. Any help is appreciated.

LPCWSTR path = L"Test String";
size_t size = wclsen(path) * sizeof(wchar_t);

DWORD dwResult = RegSetValueEx(HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\My App",
                            0,
                            REG_SZ,
                            (LPBYTE)path,
                            test);

I tried using path.size () * sizeof (wchar_t) and any number of other sizes that I could think of, but nothing seems to work. Any ideas?

+3
source share
2 answers

RegSetValueEx() REG_SZ , const TCHAR*, const CHAR* - , char* , , RegSetValueExA(). const WCHAR* RegSetValueExA(), 0x00 , .

:

  • RegSetValueExW(..., (const BYTE*) path, ...

  • CString sPath(path); RegSetValueEx(..., (const BYTE*) (LPCTSTR) sPath, ...

  • Unicode build

+7

, UNICODE/_UNICODE, .

RegSetValueExW ( L"SOFTWARE\\My App").

+2

All Articles