【问题标题】:void* pass in C# through refvoid* 通过 ref 传入 C#
【发布时间】:2012-06-22 05:47:23
【问题描述】:

vc++ dll中有一个函数。

void fun(unsigned int nchannel,int nFGHandle,void* i);

现在我想在我的 c# 代码中调用这个 dll。 我是这样用的,

[DllImport ("AVC.dll")]
public static extern void fun(UInt32 a,int b,ref void c );

所以我想问一下

  1. 是否需要编组?
  2. 如何在c#中为void* i使用ref

【问题讨论】:

标签: c# visual-c++ pointers dll dllimport


【解决方案1】:

据我所知,你使用IntPtr来封送void *,但是,如果你需要返回值,你可以直接使用out <type>并有几个重载,例如:

[DllImport ("AVC.dll")]
public static extern void fun(UInt32 a,int b, out int c );
[DllImport ("AVC.dll")]
public static extern void fun(UInt32 a,int b, out float c );

等等

【讨论】:

    猜你喜欢
    • 2010-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    • 1970-01-01
    • 2011-02-03
    • 1970-01-01
    相关资源
    最近更新 更多