c#
private delegate void ValidateEvent(int eventCode); private static void ValidateEventCallback(int eventCode)
{
Debug.Print("Validate Event:" + eventCode.ToString());
}
c++
typedef void ( *CPPCallback )(
int eventCode);
STDMETHODIMP CValidator::ValidateEvent(int procAddress)
{
// TODO: 在此添加实现代码 this->validateEventProc = (CPPCallback)procAddress;
return S_OK;
}
传入:
var method = new ValidateEvent(ValidateEventCallback);
var methodAddress = Marshal.GetFunctionPointerForDelegate(method);
securityValidator.ValidateEvent(methodAddress.ToInt32());