Files
mirror-processhacker/2.x/trunk/plugins/ProcessHacker.Api/ProcessHacker/CallbackRegistration.cs
T
dmex 50a4eea4a3 Updated Managed plugin wrapper:
-Documented APIs (where documented in PH source)
-Fixed managed signatures of native struts and functions.
-Added Handlers (Unload, Options, MenuItems)
-Removed unnecessary code

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4186 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2011-04-30 09:34:35 +00:00

35 lines
1.0 KiB
C#

using System;
using System.Runtime.InteropServices;
namespace ProcessHacker.Api
{
public unsafe class CallbackRegistration : IDisposable
{
private PhCallback* _callback;
private PhCallbackRegistration* _registration;
private PhCallbackFunction _function;
public CallbackRegistration(PhCallback* callback, PhCallbackFunction function)
{
_callback = callback;
_function = function;
_registration = (PhCallbackRegistration*)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(PhCallbackRegistration)));
NativeApi.PhRegisterCallback(_callback, function, IntPtr.Zero, _registration);
}
public void Dispose()
{
if (_registration != null)
{
NativeApi.PhUnregisterCallback(_callback, _registration);
Marshal.FreeHGlobal((IntPtr)_registration);
_registration = null;
}
}
}
}