我也问过同样的问题,这里。
我在创建返回数组对象的API方面遇到了困难。
以下是我迄今所尝试过的。我编写了将数组作为参数返回的方法。
HRESULT GetMyObjectList([out] UINT32* objCount, [out, size_is(*objCount)] MyObject myobj[*]);这给了我以下错误:Error MIDL4048 [msg]Unsupported array pattern detected. [context]myobj
此外,我还尝试将数组添加到自定义对象中,即
[version(1.0)]
typedef struct MyCustomObject
{
UINT32 count;
[size_is(count)] UINT32 someParams1[*];
} MyCustomObject;在本例中,我得到以下错误:Error MIDL4000 [msg]A structure field cannot be a type of pointer. [context]: someParams1 [ Field 'someParams1' of Struct 'MyName.Space.MyCustomObject' ]
有人能告诉我这里有什么问题吗?或提供工作示例,通过WRL检索对象数组。
发布于 2018-03-31 00:58:56
缓冲区的正确IDL取决于它是进入还是退出。
来自SDK中的windows.security.cryptography.idl:
interface ICryptographicBufferStatics : IInspectable
{
// other methods omitted...
HRESULT CreateFromByteArray([in] UINT32 __valueSize,
[in] [size_is(__valueSize)] BYTE* value,
[out] [retval] Windows.Storage.Streams.IBuffer** buffer);
HRESULT CopyToByteArray([in] Windows.Storage.Streams.IBuffer* buffer,
[out] UINT32* __valueSize,
[out] [size_is(, *__valueSize)] BYTE** value);
}注意,在WinRT中没有"by ref“数组类型--数组总是被复制的。调用方分配它,被调用方获取副本,或者被调用方分配它,调用方获得所有权。
https://stackoverflow.com/questions/49548990
复制相似问题