配置C++项目MathCon的属性配置:添加公共语言运行支持,如下图
具体调用方法如下:
#include <vcclr.h>
#using <mscorlib.dll>
#include "stdafx.h"
#include <iostream>
#include <string>
#include <atlstr.h>
using namespace System;
using namespace System::Runtime::InteropServices;
#using "F:\\ClassLibrary1\\Debug\\ADSTestLibrary.dll"
using namespace std;
using namespace ADSTestLibrary;
int _tmain(int argc, _TCHAR* argv[])
{
ADSTestLibrary::ITimsLibrary ^lib = gcnew TimsLibrary();
String ^tres = "";
int flag = 0;
lib->ITIMS_CHECK_STATION("1234567890", "SN", tres, flag);
printf("%s\n", tres);
system("pause");
return 0;
}