下面是VC代码:
#ifndef __MYPROTOCOL_H__
#define __MYPROTOCOL_H__#ifndef __DLL_MYPROTOCOL_API__
#define __DLL_MYPROTOCOL_API__   extern "C" _declspec(dllimport)
#endif#define COM_ERROR_NOT_OPENED -1
#define COM_ERROR_DATA_NULL -2
#define COM_ERROR_WRONG_DEV -3
#define COM_ERROR_TIMEOUT -4
#define COM_ERROR_DATA_INVALID -5
__DLL_MYPROTOCOL_API__ BOOL IDReaderOpen(void);
__DLL_MYPROTOCOL_API__ void IDReaderClose(void);
__DLL_MYPROTOCOL_API__ int  IDReaderGetData(UCHAR *pData, long msWaitTime);#endifVB调用dll:
Private Declare Function IDReaderOpen Lib "MyProtocol.dll" () As Boolean
Private Declare Function IDReaderClose Lib "MyProtocol.dll" ()
Private Declare Function IDReaderGetData Lib "MyProtocol.dll" (ByRef a As Byte, ByVal b As Long) As IntegerPrivate Sub Command1_Click()
    Dim a As Byte
    a = IDReaderOpen
    Text1.Text = a
End SubPrivate Sub Command2_Click()
    Call IDReaderClose
End SubPrivate Sub Command3_Click()
    Dim c1 As Byte
    Dim c2 As Long
    Text1.Text = IDReaderGetData(c1, c2)
End Sub