开发者

Cannot convert parameter from WCHAR[100] to WCHAR**

I have a method expecting WCHAR**, i need to get some data back from this method. I am declaring an array WCHAR[100]开发者_如何学JAVA 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜