문제

I have a method expecting WCHAR**, i need to get some data back from this method. I am declaring an array WCHAR[100] and passing it to the function. The compiler throws this error:

WCHAR result[100];
UINT i;
hr = SomeFunc(handle, &i, result);

error C2664: 'XXXX' : cannot convert parameter 3 from 'WCHAR [100]' to 'WCHAR **'

도움이 되었습니까?

해결책

Generally speaking, if a function takes a pointer to a pointer (WCHAR** in this case) then it will allocate its own memory and set the pointed-to pointer to that memory. The documentation of SomeFunc should describe if this is indeed what happens.

If that is the case, then you would likely need something like:

WCHAR* result = NULL;
UINT i;
hr = SomeFunc(handle, &i, &result);

And then make use of result if successful.

Of course, in that case you also most likely need to worry about deallocating the memory that result was set to point to. The documentation of SomeFunc should explicitly say what's necessary to do that as well.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top