[英]Pointer to function for unmanaged code in C#
I have a dll which accepts a struct that contains a pointer to a function to do a callback. 我有一个接受一个结构的DLL,该结构包含一个指向函数的指针来进行回调。
How can I get an IntPtr to a function of my application to build the struct? 如何将IntPtr作为我的应用程序的函数来构建结构?
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class OPERATION {
public uint OperationID;
public IntPtr Context;
public IntPtr Callback; -> How to pass this?
}
Here is the delegate accepting the OPERATION struct 这是委托接受OPERATION结构
public delegate void MY_CALLBACK([In] OPERATION operation, [In] uint msgId, [In] IntPtr msgDataPtr);
也许Marshal.GetFunctionPointerForDelegate方法可以帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.