VS2010开发——vc++项目编写DLL提供vb.net调用



VS2010开发—vc++项目编写DLL提供vb.net调用

望断—编程步骤如下:

1. 打开VS2010开发软件建立vc++的Win32 Project项目(名称wang_duan);选择单点“DLL”与单点“Export symbols”,不需要点击“Empty project”,完成项目建立。

2. 删除wang_duan.cpp 与 wang_duan.h 文件内容,并在项目属性对话框中选择"C/C++"|"Advanced",将Compile AS 选项的值改为"C++"。

3. wang_duan.h文件里面程序:

#define TESTCPPDLL_API _declspec(dllexport)

EXTERN_C TESTCPPDLL_API int quitLoop(int wang, int duan);

4.wang_duan.cpp 文件里面程序:

#include "stdafx.h"
#include "wang_duan.h"

TESTCPPDLL_API int quitLoop(int wang, int duan)
{
	return wang + duan;
}

5. 编译通过后,在文件夹的Debug复制dll文件到vb.net文件夹的Debug;进行调用程序编写:

6. 最后在vb.net程序中的编程:

Public Class Form1
    'VB程序动态库调用的定义
    Private Declare Function quitLoop Lib "wangduan.dll" (ByVal x_wang As Integer, ByVal y_duan As Integer) As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim qiugao As Integer = 0
        qiugao = quitLoop(2, 3)
        TextBox1.Text = qiugao
    End Sub
End Class

备注:望断_秋高——编程调试通过的(聪明的你;vb.net知道结果显示:5)!!



  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值