110,567
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
extern "C" _declspec(dllexport) int sum(int a, int b)
{
return a+b;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace ImportCplusDll
{
class Program
{
[DllImport("c++_dll.dll", EntryPoint = "sum", CharSet = CharSet.Auto,CallingConvention = CallingConvention.StdCall)]
public static extern int sum(int a, int b);
static void Main(string[] args)
{
int result = sum(3,5);
Console.WriteLine(result);
Console.ReadKey();
}
}
}