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

来源:互联网 发布:php is_empty_array 编辑:程序博客网 时间:2024/05/20 19:30


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 SubEnd Class

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



1 0
原创粉丝点击