Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You probably need to use the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.getdelegateforfunctionpointer.aspx" rel="nofollow"><code>Marshal.GetDelegateForFunctionPointer</code> function</a></p> <p>This takes an <code>IntPtr</code> pointing to a native method and gives you back a delegate you can call.</p> <pre><code>public struct test { IntPtr API_GetUID; IntPtr API_GetChipType; } [DllImport(@"GDevice.dll")] public static extern void GetAPIObject(ref test test_a); delegate void GetUID_Delegate(IntPtr pData, uint dataLen); delegate uint GetChipType_Delegate(); test a = new test(); GetAPIObject(ref a); GetUID_Delegate getUID = Marshal.GetDelegateForFunctionPointer&lt;GetUID_Delegate&gt;(a.API_GetUID); GetChipType_Delegate getChipType = Marshal.GetDelegateForFunctionPointer&lt;GetChipType_Delegate&gt;(a.API_GetChipType); uint chipType = getChipType(); </code></pre> <h1>Edit</h1> <p>Alternatively use <a href="http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.unmanagedfunctionpointerattribute.aspx" rel="nofollow">UnmanagedFunctionPointerAttribute</a>. </p> <pre><code>public struct test { GetUID_Delegate API_GetUID; GetChipType_Delegate API_GetChipType; [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate void GetUID_Delegate(IntPtr pData, uint dataLen); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate uint GetChipType_Delegate(); } [DllImport(@"GDevice.dll")] public static extern void GetAPIObject(ref test test_a); test a = new test(); GetAPIObject(ref a); uint chipType = a.API_GetChipType(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload