Registering _set_purecall_handler function using P/Invoke in C#

前端 未结 1 447
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-27 01:16

I\'m having trouble using _set_purecall_handler with P/Invoke in C#.

Basically, this works:

(C++)

_set_purecall_handler(MyPureCa         


        
1条回答
  •  感情败类
    2021-01-27 01:56

    After trial and error, I found that referencing msvcr100d.dll (d = debug) instead of msvcr100.dll worked as I was under the debugger.

    Here's my source (I don't know if this is good practice, but I've successfully tested under debug / release mode):

    private const string DllName =
        #if DEBUG
            "msvcr100d.dll";
        #else
            "msvcr100.dll"; 
        #endif
    
    public delegate void PureCallHandler();
    
    [DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
    public static extern PureCallHandler _set_purecall_handler(PureCallHandler handler);
    

    0 讨论(0)
提交回复
热议问题