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