这是在vc中的调用过程:
这是:EasyIrqSample.cpp
#include <windows.h>
#include <conio.h>
#include "easyirq.h"// the function that is called every IRQ
void __stdcall irqHandler(DWORD irqNum) {
    MessageBox(0, "IRQ here !", "", 0);
}int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow) {
// turn on IRQ 7 handling
    if ( easyIrq(7, TRUE, &irqHandler) ) {
        MessageBox(0, "some error", "error", 0);
        return 1;
    }
    // just wait irqs
MessageBox(0, "click OK to finish", "", 0);
    // turn off IRQ 7 handling (mask irq)
    easyIrq(7, FALSE, &irqHandler);
    return 0;
}
这是:EasyIrq.h
extern "C" DWORD __stdcall easyIrq(DWORD irqNumber, DWORD onoff, void (__stdcall *callbackfunction)(unsigned long));// return values of easyIrq function
#define EASY_IRQ_ERR_CANT_LOAD_DRIVER 1
#define EASY_IRQ_ERR_CANT_CALL_OPENVXDHANDLE 2
#define EASY_IRQ_ERR_CANT_CREATE_EVENT 3
#define EASY_IRQ_ERR_DEVICEIOCONTROL_ON 4
#define EASY_IRQ_ERR_CANT_OPEN_IRQ 5
#define EASY_IRQ_ERR_DEVICEIOCONTROL_OFF 6
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
这是vb的调用过程未通过:
form1中的代码:
Private Sub Command1_Click()
Call easyIrq(7,  true,address0f cout)
End Sub
Private Sub Command1_Click()
Call easyIrq(7, ByVal true,address0f cout)
End SubModule1中的代码:
Public Declare Function easyIrq Lib "EasyIrq.dll" _
(ByVal irqNumber As Long, ByVal onoff As Long, ByVal callbackfunction As Long) As Long
Public count As Long
Public Sub cout(coun As Long)
count = count + 1
End Sub

解决方案 »

  1.   

    没用过
    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=183785
    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=188988
      

  2.   

    callbackfunction
    这是要调用的函数,是由自己写的,它在这里的作用应该是相当于一个参数。
      

  3.   

    VB如何调用VC开发的DLL,请大虾看小弟的做法
    http://www.csdn.net/expert/topic/598/598731.xml?temp=.4895441DLL怎样调用呀???
    http://www.csdn.net/expert/topic/594/594178.xml?temp=.8628961关于VB中调用dll问题
    http://www.csdn.net/expert/topic/593/593058.xml?temp=8.231753E-02 请问在VB中如何声明未注册的。DLL文件 
    http://www.csdn.net/expert/topic/596/596013.xml?temp=.4934809: VB6中调用DLL函数, 如何写Declare.
    http://www.csdn.net/expert/topic/588/588144.xml?temp=.7685663VB里怎样调用VC的DLL
    http://www.csdn.net/expert/topic/578/578848.xml?temp=.1891901如何注册dll
    http://www.csdn.net/expert/topic/575/575344.xml?temp=.9700128vb中访问dll的问题
    http://www.csdn.net/expert/topic/583/583120.xml?temp=.7625543我在VB中调用VC下写的DLL为何总是提示
    http://www.csdn.net/expert/topic/587/587125.xml?temp=.6232721
      

  4.   

    在VB工程中使用VC++编写的动态联接库
     
    1、在VC++中新建MFC AppWizard(DLL)工程vcdll:
    vcdll.cpp的代码如下:
    #include "stdafx.h"
    #include "vcdll.h"long sum1(); //无参类型
    extern "C" int APIENTRY sum2(int i); //从VB中接收一个参数
    extern "C" long APIENTRY sum3(int i,int j); //从VB中接收两个参数#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endifBEGIN_MESSAGE_MAP(CVcdllApp, CWinApp)END_MESSAGE_MAP()CVcdllApp::CVcdllApp()
    {
    }CVcdllApp theApp;long sum1()
    { return 100+200; }extern "C" int APIENTRY sum2(int i)
    { i+=100;
    return i;
    }extern "C" long APIENTRY sum3(int i,int j)
    { return i+j;
    }2、在vcdll.def中的代码如下:
    LIBRARY "vcdll"
    DESCRIPTION 'vcdll Windows Dynamic Link Library'EXPORTS
    ; Explicit exports can go here
    sum1
    sum2
    sum3
    3、在编译后,把vcdll.dll拷贝到Windows目录下。
    4、VB中新建标准EXE工程vb_vcdll,vb_vcdll.frm的代码如下:
    Private Declare Function sum1 Lib "vcdll.dll" () As Long 
    Private Declare Function sum2 Lib "vcdll.dll" (ByVal i As Integer) As Integer 
    '声明VC库中的函数
    Private Declare Function sum3 Lib "vcdll.dll" (ByVal i As Integer, ByVal j As 
    Integer) As LongPrivate Sub Command1_Click()
    Text1.Text = sum1() '调用VC函数
    End SubPrivate Sub Command2_Click()
    Text1.Text = sum2(110)
    End SubPrivate Sub Command3_Click()
    Text1.Text = sum3(100, 250)
    End Sub
     
      

  5.   

    你说的函数我也会用
    我是想知道我问的这个怎么用
    关键是这个
    extern "C" DWORD __stdcall easyIrq(DWORD irqNumber, DWORD onoff, void (__stdcall *callbackfunction)(unsigned long));
    没看到过有人用VB调用这样的东西