下面是C++代码 /* 创建实例句柄 */
ret = m_proc.ISECreateInst(&m_ise_inst,m_proc.pICB /*异步方式*/, this /*user_data*/, NULL/* params */);
这是我用Pinvoker生成的接口        [DllImport(DllPath,
            SetLastError = true,
            CallingConvention = CallingConvention.StdCall)]
        public extern static int ISECreateInst(
            ref ISE_INST  ise_inst,
            ISEEVENTCB callback,
            IntPtr user_data,
            [MarshalAs(UnmanagedType.LPWStr)] string params_);
第二个参数,C++里需要把类实例传进去了,然后在一个回调里强制转化回来.那么我在C#里面怎么做呢?
托管里的类实例,怎么转化成 InPtr 呢?

解决方案 »

  1.   

    [DllImport("lis_interface.dll",
                EntryPoint = "charge_confirm",
                SetLastError = true,
                CharSet = CharSet.Ansi,
                ExactSpelling = true,
                CallingConvention = CallingConvention.StdCall)]
            public static extern int charge_confirm(string jyapply_no, string flag);
      

  2.   

    InPtr是句柄,每个窗体都有的handle
      

  3.   


    我换个思路不按C++那样把this传进去了,传个空指针,在回调里直接使用当前实例中的this.PS:ls更扯了