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++混用,各取所長。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章