Code blocks 创建DLL,并在C#中引入

1、在Code blocks 工程头文件里加上(如果没有)

  1. #ifdef __cplusplus  
  2. #define EXPORT extern "C" __declspec (dllexport)  
  3. #else  
  4. #define EXPORT __declspec (dllexport)  
  5. #endif // __cplusplus  
int EXPORT test( int a );

在c文件里实现

int EXPORT test( int a );

2、在C#中引入DLL,digest.dll 为动态链接库名称,test为引入的函数名

[System.Runtime.InteropServices.DllImport("digest.dll", EntryPoint = "test")]
static extern int test(int a);

猜你喜欢

转载自blog.csdn.net/csd_meb/article/details/79087732