首先是c++写的声明文件

c#调用c++写成的dll文件// Inclusion guard
c#调用c++写成的dll文件
#ifndef _DLLTUT_DLL_H_
c#调用c++写成的dll文件
#define _DLLTUT_DLL_H_
c#调用c++写成的dll文件
c#调用c++写成的dll文件
// Make our life easier, if DLL_EXPORT is defined in a file then DECLDIR will do an export
c#调用c++写成的dll文件
// If it is not defined DECLDIR will do an import
c#调用c++写成的dll文件
#if defined DLL_EXPORT
c#调用c++写成的dll文件
#define DECLDIR __declspec(dllexport)
c#调用c++写成的dll文件
#else
c#调用c++写成的dll文件
#define DECLDIR __declspec(dllimport)
c#调用c++写成的dll文件
#endif
c#调用c++写成的dll文件
c#调用c++写成的dll文件
// Specify "C" linkage to get rid of C++ name mangeling
c#调用c++写成的dll文件
extern "C"
#endif

测试程序的目录结构

c#调用c++写成的dll文件

测试代码c#

c#调用c++写成的dll文件using System;
c#调用c++写成的dll文件
using System.Collections.Generic;
c#调用c++写成的dll文件
using System.Text;
c#调用c++写成的dll文件
using System.Runtime.InteropServices;
c#调用c++写成的dll文件
c#调用c++写成的dll文件
namespace ConsoleApplication30

相关文章:

  • 2021-07-29
  • 2021-11-08
  • 2021-10-26
  • 2022-12-23
  • 2021-08-17
  • 2022-12-23
  • 2021-12-27
  • 2022-01-10
猜你喜欢
  • 2021-12-28
  • 2021-07-18
  • 2021-12-04
  • 2021-11-26
  • 2022-01-14
  • 2022-02-02
相关资源
相似解决方案