private void CallUnamanged() { IntPtr dll = NativeMethods.LoadLibrary(Path); if (dll == IntPtr.Zero) { throw new Exception("Can't open DLL file!"); } IntPtr procAddr = NativeMethods.GetProcAddress(dll, Identifier); if (procAddr == IntPtr.Zero) { throw new Exception("Can't find " + Identifier + " in DLL!"); } UnmanagedCallback callback = (UnmanagedCallback) Marshal.GetDelegateForFunctionPointer(procAddr, typeof(UnmanagedCallback)); callback(Body); NativeMethods.FreeLibrary(dll); }
static public extern int setCallback(UnmanagedCallback callback);
public static extern int setCallback(UnmanagedCallback callback);