Win32旧版应用程序中的拦截器

时间:2020-07-21 06:15:00

标签: .net winapi aop

在C#中,我们使用Castle.DynamicProxy.IInterceptor截取用于记录目的的方法调用,我们对参数和返回值感兴趣,例如:

    public void Intercept(IInvocation invocation)
    {
        Debug(invocation.Method.DeclaringType.Name + "." + invocation.Method.Name + "(" + string.Join(", ", invocation.Arguments.Select(a => (GetValue(a) ?? "").ToString()).ToArray()) + ")");
        invocation.Proceed();

        string returnValue = GetValue(invocation.ReturnValue);

        Debug($"{invocation.Method.DeclaringType.Name}.{invocation.Method.Name}.Result: {returnValue}");
    }

我们有一个Win32应用程序,我们希望对此做类似的事情。不必在每个方法中都放入跟踪语句,这是否有可能?有没有办法像Win32中的.net那样拦截方法调用?该语言称为可视对象。

谢谢

0 个答案:

没有答案
相关问题