c++调用.NET dll

  • 首先新建一个c++应用程序(我选的是控制台应用程序+window) 2.0

这里写图片描述

  • 配置属性

这里写图片描述

  • 引用.NET dll
#using "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll"
#using "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll"
#using "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll"
#using "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll"
#using "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll"

using namespace System;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Xml;
using namespace System::IO;
using namespace System::Windows::Forms;

简单的使用示例:

   // 全写
   System::String ^str = "This is the C # object";
   System::Windows::Forms::MessageBox::Show(str);
   // 简写
   String ^str = "This is the C # object";
   MessageBox::Show(str);

C#与C++混用,各取所长。

猜你喜欢

转载自blog.csdn.net/yangsen600/article/details/62044679