惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
大猫的无限游戏
大猫的无限游戏
B
Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Jina AI
Jina AI
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
L
LangChain Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
F
Fortinet All Blogs
H
Help Net Security
B
Blog RSS Feed
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题

博客园 - jasonM

真是郁闷,团队中居然出了这样的骗子!! C++反汇编揭秘1 – 一个简单C++程序反汇编解析 函数调用堆栈变化分析 - jasonM - 博客园 为什么要下断bpSend,原理分析。 做挂第一步:如何找基址(以热血传奇为例) 一步步学外挂(二).CALL的原理。 - jasonM - 博客园 开发企业直销软件需求分析 开发旺旺群发软件,难点及重要技术点分析(一) 正则表达式系列文章整理 群发软件开发原理分析 通俗解释socket(并附上注释Socket源代码) CMainFrame::PreCreateWindow这个函数执行了两次 一步步学破解-sdk用实例讲解GDI映射机制 一步步学破解-sdk用实例讲解GDI(含各个消息的调用时机) 一步步学破解-sdk进程间传递信息 一步步学破解-在已有的主窗口上创建按钮(三) 一步步学破解-windows消息循环原理实例总结(二) 一步步学破解-函数调用堆栈变化分析 (一) 老王最新壳试脱时遇到的问题,详细表述如下
.net调用vc++写的dll
jasonM · 2009-06-03 · via 博客园 - jasonM

1.vc做的win32的dll,其中dll2.cpp文件代码如下:

int add(int a,int b)
{

 return a+b+1;
}

int subtract(int a,int b)
{
 return a-b;
}

2.dll2.def代码如下:

LIBRARY dll2
EXPORTS
add
subtract

3.将dll2.lib和dll2.dll拷到c#当前目录下

4.建立测试用的.net程序,代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;   

namespace WindowsApplication1
{


    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {


        }

        private void button1_Click(object sender, EventArgs e)
        {
           int nindex=Name1.add(2,0);
        }
    }

    public class Name1
    {

        //导入dll

        [DllImport("dll2.dll", CallingConvention = CallingConvention.StdCall)]

        //声明接口函数

        public static extern int add(int a, int b);

    }
}