博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c# 调用 c++写的DLL
阅读量:4597 次
发布时间:2019-06-09

本文共 501 字,大约阅读时间需要 1 分钟。

150832071248063.png
解决办法 安装 vcredist 运行库 或者用VC6.0编写DLL

Win32 dll
新建项目, Win32项目
Win32Project1.cpp
// Win32Project1.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
extern "C" __declspec(dllexport) int add(int x,int y)
{
    return x + y;
}
 
150832111397523.png
150832121393695.png
创建c#程序  将编译好的程序 放到 c#的RELEASE目录下
        [System.Runtime.InteropServices.DllImport("Win32Project1.dll")]
        private static extern int add(int xint y);
        private void button1_Click(object senderEventArgs e)
        {
            MessageBox.Show(add(9, 9).ToString());
        }

转载于:https://www.cnblogs.com/xe2011/p/3789082.html

你可能感兴趣的文章
hdu 1025
查看>>
jar war ear
查看>>
CheckBox自定义样式
查看>>
史上最全的程序猿面试资料
查看>>
什么是分布式消息中间件?
查看>>
linux命令 xargs
查看>>
pythonic operations
查看>>
idea如何打开右侧工具栏
查看>>
msyql数据库位置
查看>>
POJ 3253 Fence Repair 贪心+优先队列
查看>>
java导出csv 代码
查看>>
16个ASP.NET MVC扩展点【附源码】
查看>>
观察者模式(observer)
查看>>
路由处理生成响应
查看>>
w3school HTML基础教程
查看>>
在centos下解决 “致命错误:curses.h:没有那个文件或目录”
查看>>
程序员必学的职场人际关系22原则
查看>>
css3的transition效果和transfor效果
查看>>
[置顶] 小白学习KM算法详细总结--附上模板题hdu2255
查看>>
POJ 2400 最小权匹配
查看>>