c++调用.NET dll

来源:互联网 发布:知乎用户数据分析 编辑:程序博客网 时间:2024/05/01 08:31
  • 首先新建一个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++混用,各取所长。

0 0
原创粉丝点击