c#调用C++ 方式有2种
- 第一种:C++ 生成的非托管代码dll,C#通过DllImport方式进行调用(类似于.net调用win32API一样)
[DllImport("KERNEL32.DLL", EntryPoint="MoveFileW", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool MoveFile(String src, String dst);
-
第二种:C++ 托管代码(用托管C++包装现有的dll,提供给C#调用)有2种方式:
- 使用C++/Managed代码来包装(已过时)
-
使用 C++/CLI
#include <curl\curl.h>
ref class CuryEasy
{
public:
CurlEasy()
{
easy = curl_easy_init();
}
private:
CURL* easy;
}