C#引用C++的DLL方案(C#调用非托管动态链接库)

        SocketClientInit是C++里面定义的方法,通过EntryPoint = "[email protected]@[email protected]"指出这个函数的真正入口处,方法是在运行指令中输入

        dumpbin -exports +dll 路径:dumpbin -exports C:\Users\Administrator\Desktop\C++Dll\C++Dll\bin\Debug\NcPcCom.dll

        C#引用C++的DLL方案(C#调用非托管动态链接库)

        [DllImport("NcPcCom.dll", EntryPoint = "[email protected]@[email protected]", CallingConvention = CallingConvention.Cdecl)]
        public static extern int SocketClientInit(int TimeOut, int TimeOutCnt, ref string Ver);
        public int socketClientInit(int TimeOut, int TimeOutCnt, ref string Ver)
        {
            return SocketClientInit(TimeOut, TimeOutCnt, ref Ver);
        }