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

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

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

        C#引用C++的DLL方案(C#调用非托管动态链接库)_第1张图片

        [DllImport("NcPcCom.dll", EntryPoint = "?SocketClientInit@@YAHHHPAD@Z", 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);
        }

转载于:https://www.cnblogs.com/JackMo/p/7435226.html

你可能感兴趣的:(C#引用C++的DLL方案(C#调用非托管动态链接库))