C# 调用 C++ Dll

C# 调用 C++ Dll,第1张

C# 调用 C++ Dll 1.C++生成DLL

参考:https://blog.csdn.net/qq_41374107/article/details/106021015

2.C#调用

参考:https://blog.csdn.net/guangod/article/details/85774225

namespace Dll2
{
    class Program
    {
        [DllImport("Dll2.dll", EntryPoint = "myAdd", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
        private static extern int Add(int a, int b);
        [DllImport("Dll2.dll", EntryPoint = "myMax", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
        private static extern int Max(int a, int b);
        static void Main(string[] args)
        {
            Console.WriteLine(Add(1,2));
            Console.WriteLine(Max(1,2));
            Console.ReadKey();
        }
    }
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/562987.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-02
下一篇 2022-04-02

发表评论

登录后才能评论

评论列表(0条)

保存