c++调用 c#的dll
来源:互联网 发布:e盾网络验证容易破解吗 编辑:程序博客网 时间:2024/05/29 18:28
http://my.oschina.net/u/929434/blog/98649
以vs2012为例
1 用c#输出dll
(1)打开vs2012
(2)文件->新建->项目->c#->类库
(3)输入代码
01
using
System;
02
using
System.Collections.Generic;
03
using
System.Linq;
04
using
System.Text;
05
using
System.Threading.Tasks;
06
using
System.Windows.Forms;
07
08
09
namespace
ClassLibrary1
10
{
11
public
class
Class1
12
{
13
public
void
ShowMessage()
14
{
15
Console.WriteLine(
"成功调用了dll"
);
16
Console.ReadLine();
17
}
18
19
public
void
ShowMessageBox()
20
{
21
MessageBox.Show(
"调用了Dll"
,
"调用"
,
22
MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
23
}
24
25
public
int
ShowArr(
double
[] a,
int
n)
26
{
27
for
(
int
i = 0; i <= n; i++)
28
{
29
Console.WriteLine(
"a[{0}]={1}\n"
, i, a[i]);
30
}
31
return
0;
32
}
33
}
34
}
(4)生成(B)->生成 ...(U)
(5)产生了一个dll文件
(6)新建一个c++项目,项目属性中 将 公共语言运行支持 选为 公共运行时支持(/clr)
(7)VC++目录中 将dll文件所在目录 添加到 可执行文件目录 包含目录 引用目录 库目录
(8)在VC++中写入代码
01
// ConsoleApplicationdll.cpp : 定义控制台应用程序的入口点。
02
//
03
04
#include "stdafx.h"
05
#using "ClassLibrary1.dll"
06
using
namespace
ClassLibrary1;
07
08
int
_tmain(
int
argc, _TCHAR* argv[])
09
{
10
Class1 ^c=gcnew Class1();
11
cli::array<
double
,1>^a=gcnew cli::array<
double
>(5);
12
for
(
int
i=0;i<5;i++){
13
a[i]=i+0.1;
14
}
15
int
n=4;
16
//c->ShowMessage();
17
c->ShowMessageBox();
18
c->ShowArr(a,n);
19
return
0;
20
}
0 0
- C#调用C的DLL
- C#调用C++DLL
- C#调用C++dll
- C#调用C++dll
- C#调用C++DLL
- c#调用c++DLL
- C# 调用C++dll
- C#调用C++DLL
- C#调用C++DLL
- C#调用C++DLL
- C#调用C++Dll
- C#调用C++DLL
- C#调用C++DLL的方法
- C#动态调用c++DLL的方法
- 编写C#调用的C++DLL
- 编写C#调用的C++DLL
- C#调用C++dll的类型转换
- c#调用C/C++生成的dll
- 安装64位win7后配置php mysql Apache 遇到问题并解决~~
- Oracle8i到Oracle11g的主要变化
- 115家IT公司待遇一览表
- 突破数据库防下载的简单几招
- UVA10033
- c++调用 c#的dll
- python 打印当前时间
- HSSFWorkbook 与 XSSFWorkbook
- 多线程安全问题的解决方法一
- 2.6 python中的字典 [python入门教程]
- POJ:3320 Jessica's Reading Problem
- Coursera 《机器学习》(Lecture 05)
- [金融之王:毁了世界的银行家]
- Knight Moves(BFS)