jiten
jiten

Reputation: 5264

void* pass in C# through ref

There is a function in vc++ dll.

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

Now I want to call this dll in my c# code. I am using like this,

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

So I want to ask

  1. Is there any need of marshling?
  2. how to use ref for void* i in c#

Upvotes: 0

Views: 759

Answers (1)

Jcl
Jcl

Reputation: 28272

As far as I know, you use IntPtr to marshal void *, however, if you need the return value, you can directly use out <type> and have several overloads, e.g.:

[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 );

etc.

Upvotes: 2

Related Questions