I try the following code:
public delegate Int32 capErrorCallback(IntPtr hWnd, Int32 nID,
[MarshalAs(UnmanagedType.LPWStr)]
String lpsz);
public static Boolean capSetCallbackOnError(IntPtr hwnd, capErrorCallback errorCallback)
{
return AVICapSendMessage(hwnd, WM_CAP_SET_CALLBACK_ERRORW, 0,
(Int32)errorCallback.Method.MethodHandle.Value) == 0 false : true;
}
but the code looks doesn't work, the error cause a NullReferenceException. I am not sure which cause the problem. Could anybody give any advice

How to wrap the capSetCallbackXXXXXX function
Alan1203
Lee Meyers
Kapil Singhal
I solved this problem by using the new GetFunctionPointerForDelegate function in .NET 2.0.
public static Boolean capSetCallbackOnError(IntPtr hwnd, capErrorCallback errorCallback)
{
IntPtr ad = Marshal.GetFunctionPointerForDelegate(errorCallback);
return AVICapSendMessage(hwnd, WM_CAP_SET_CALLBACK_ERRORW, 0,
(Int32)ad) == 0 false : true;
}