ComInterop将托管float []用作ref float [英] ComInterop pass managed float[] as ref float

查看:75
本文介绍了ComInterop将托管float []用作ref float的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ComInterop方法,其托管代码(C#)中的签名为 void Foo(ref SOME_ENUM,ref float,ref int) 其中SOME_ENUM是.NET枚举

I have a ComInterop method with the signature in managed code (C#) of void Foo(ref SOME_ENUM, ref float, ref int) where SOME_ENUM is a .NET enum

实际的非托管代码需要SOME_ENUM,float和int参数的固定大小的数组.

The actual unmanaged code wants fixed size arrays for the SOME_ENUM, float, and int parameters.

我使用midl.exe和tlbimp.exe创建托管包装dll.

I used midl.exe and tlbimp.exe to create the managed wrapper dll.

如何将float [],enum [],int []作为ref float,ref int,ref enum传递给非托管代码?

由于库中有大量的类,所以我无法手工拼凑库的[ComImport].

I can't cobble together the [ComImport] for the library by hand because there are a massive amount of classes in the library.

 

推荐答案

如果无法调整定义,请检查本机代码通过此调用接收预期的数据:

    Foo(ref e [0],ref f [0],ref i [0]);

    Foo( ref e[0], ref f[0], ref i[0]);

其中 e f i 是数组.

where e, f and i are arrays.


这篇关于ComInterop将托管float []用作ref float的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆