cunicodenvapi

Assign string to NvAPI_UnicodeString


Now I'm working on NVAPI.

There is a type "NvAPI_UnicodeString".

It is a unsigned short array.

typedef NvU16 NvAPI_UnicodeString[NVAPI_UNICODE_STRING_MAX];
typedef unsigned short   NvU16;

and there is a type "NvAPI_LPCWSTR", also.

typedef const NvU16 *NvAPI_LPCWSTR;

I want assign a value to NvAPI_UnicodeString like

NvAPI_UnicodeString = L"Hello";

But it doesn't work.

Please let me know how to solve it.

Thanks.


Solution

  • You cannot assign an array using the = operator. You have to use memcpy or memcpy_s

    NvAPI_UnicodeString wsz;
    memcpy_s(wsz, sizeof(wsz), L"Hello", 6*sizeof(wchar_t));