I have a C function with prototype, void* VoidPointer(void*); Now I need to marshal it in C#(using DllImport). But I do not know how to mention the parameters in C# code.
I am new to C# and need to solve this asap ( in several attempts have got errors like this cannot convert from 'int' to 'System.IntPtr') Thanks.
c# supports void pointers. Just declare the function as
[DllImport("test.dll")]
public static extern unsafe void* VoidPointer(void* AValue);
public unsafe void Test()
{
int* a;
int b = 0;
a = (int*)VoidPointer(&b);
}
(this only works if the void pointers are referencing integers ofcourse)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.