请懂BC的帮个忙!

hzc1 2008-01-21 11:19:56
我有一个C的头文件,我需要将它翻译成VB的模块文件。
代码如下:
#define STX 0x20
#define ACK 0x06
#define NAK 0x15
#define ETX 0x03

#define SEQNR 0
#define COMMAND 1
#define STATUS 1
#define LENGTH 2
#define DATA 3

//mifare error
#define MI_OK 0
#define MI_NOTAGERR 1
#define MI_EMPTY 3
#define MI_AUTHERR 4
#define MI_PARITYERR 5
#define MI_CODEERR 6

#define MI_SERNRERR 8
#define MI_NOTAUTHERR 10
#define MI_BITCOUNTERR 11
#define MI_BYTECOUNTERR 12
#define MI_TRANSERR 14
#define MI_WRITEERR 15
#define MI_INCRERR 16
#define MI_DECRERR 17
#define MI_READERR 18
#define MI_QUIT 30

//check write Error
#define MIS_CHK_OK 0
#define MIS_CHK_FAILED 1
#define MIS_CHK_COMPERR 2


//typedef unsigned char (CALLBACK* LPZLGB_READ)(unsigned char, unsigned char*);

typedef unsigned char (CALLBACK* LPZLGB_REQUEST)(unsigned char ,unsigned short *);
typedef unsigned char (CALLBACK* LPZLGB_ANTICOLL)(unsigned char ,unsigned long *);
typedef unsigned char (CALLBACK* LPZLGB_ANTICOLL2)(unsigned char ,unsigned char ,unsigned long *);
typedef unsigned char (CALLBACK* LPZLGB_SELECT)(unsigned long ,unsigned char *);
typedef unsigned char (CALLBACK* LPZLGB_AUTHENTICATION)(unsigned char ,unsigned char );
typedef unsigned char (CALLBACK* LPZLGB_AUTHENTICATION2)(unsigned char ,unsigned char,unsigned char);
typedef unsigned char (CALLBACK* LPZLGB_HALT)(void);
typedef unsigned char (CALLBACK* LPZLGB_READ)(unsigned char ,unsigned char *);
typedef unsigned char (CALLBACK* LPZLGB_WRITE)(unsigned char ,unsigned char *);
typedef unsigned char (CALLBACK* LPZLGB_INCREMENT)(unsigned char ,long *);
typedef unsigned char (CALLBACK* LPZLGB_DECREMENT)(unsigned char ,long *);
typedef unsigned char (CALLBACK* LPZLGB_WRITEVAL)(unsigned char ,long );
typedef unsigned char (CALLBACK* LPZLGB_READVAL)(unsigned char ,long *);
typedef unsigned char (CALLBACK* LPZLGB_CHANGEPWD)(unsigned char ,unsigned char,unsigned char *);
typedef unsigned char (CALLBACK* LPZLGB_RESTORE)(unsigned char );
typedef unsigned char (CALLBACK* LPZLGB_TRANSFER)(unsigned char );
typedef unsigned char (CALLBACK* LPZLGB_VALUE)(unsigned char,unsigned char,long *,unsigned char);
typedef unsigned char (CALLBACK* LPZLGB_LOAD_KEY)(unsigned char,unsigned char,unsigned char *);
typedef unsigned char (CALLBACK* LPZLGB_RESET)(unsigned char);
typedef unsigned char (CALLBACK* LPZLGB_CLOSE)(void);
typedef unsigned char (CALLBACK* LPZLGB_CONFIG)(void);
typedef unsigned char (CALLBACK* LPZLGB_GET_INFO)(unsigned char *);
typedef unsigned char (CALLBACK* LPZLGB_CHECK_WRITE)(unsigned char,unsigned char,unsigned char,unsigned char *);
typedef unsigned char (CALLBACK* LPZLGB_SET_CONTROL_BIT)();
typedef unsigned char (CALLBACK* LPZLGB_CLR_CONTROL_BIT)();
typedef unsigned char (CALLBACK* LPZLGB_BUZZER)(unsigned char,unsigned char,unsigned char,unsigned char);
typedef unsigned char (CALLBACK* LPZLGB_READ_E2)(unsigned char,unsigned char ,unsigned char *);
typedef unsigned char (CALLBACK* LPZLGB_WRITE_E2)(unsigned char,unsigned char,unsigned char *);
typedef unsigned char (CALLBACK *LPZLGB_INIT)(int , int );
typedef void (CALLBACK* LPZLGB_EXIT)(void);
...全文
58 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hzc1 2008-01-21
  • 打赏
  • 举报
回复
好,先谢谢,我先改改,有问题再请教,待会儿就结贴
chenhui530 2008-01-21
  • 打赏
  • 举报
回复
unsigned char对应是byte
long *表示指针,你改地址传递Byref
hzc1 2008-01-21
  • 打赏
  • 举报
回复
哦,那long 也对应long 是吧
还有这个,unsigned char,long *,这个怎么写呢?

不好意思,麻烦了
chenhui530 2008-01-21
  • 打赏
  • 举报
回复
那我只给你翻译一个其他的你自己照着来就行了

typedef unsigned char (CALLBACK* LPZLGB_REQUEST)(unsigned char ,unsigned short *);

Private Declare Function Lpzlgb_Request Lib "zlg500b.dll" (ByVal bytBuffer As byte,Byref intBuffer as integer) As Long

其中函数名(Lpzlgb_Request)必须和库中的名字一样区分大小写的
hzc1 2008-01-21
  • 打赏
  • 举报
回复
不好意思,库文件是zlg500b.dll
chenhui530 2008-01-21
  • 打赏
  • 举报
回复
上面的都是定义常量
下面类似typedef的是API函数指针
你得把库文件说出来不然不好给你定义

上面的#define 可以改成const
比如#define STX 0x20 改成const STX =&H20
chenhui530 2008-01-21
  • 打赏
  • 举报
回复
应该差不多了
hzc1 2008-01-21
  • 打赏
  • 举报
回复
请帮我瞧瞧,我改得对吗?谢了~~~~~~
'typedef unsigned char (CALLBACK* LPZLGB_REQUEST)(unsigned char ,unsigned short *);
Private Declare Function LPZLGB_Request Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_ANTICOLL)(unsigned char ,unsigned long *);
Private Declare Function LPZLGB_ANTICOLL Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_SELECT)(unsigned long ,unsigned char *);
Private Declare Function LPZLGB_SELECT Lib "zlg500b.dll" (ByVal bytBuffer As Long, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_AUTHENTICATION)(unsigned char ,unsigned char );
Private Declare Function LPZLGB_AUTHENTICATION Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByVal intBuffer As Byte) As Long

'typedef unsigned char (CALLBACK* LPZLGB_AUTHENTICATION2)(unsigned char ,unsigned char,unsigned char);
Private Declare Function LPZLGB_AUTHENTICATION2 Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByVal intBuffer As Byte, ByVal INT2 As Byte) As Long

'typedef unsigned char (CALLBACK* LPZLGB_HALT)(void);
Private Declare Function LPZLGB_HALT Lib "zlg500b.dll" () As Long

'typedef unsigned char (CALLBACK* LPZLGB_READ)(unsigned char ,unsigned char *);
Private Declare Function LPZLGB_READ Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_WRITE)(unsigned char ,unsigned char *);
Private Declare Function LPZLGB_WRITE Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_INCREMENT)(unsigned char ,long *);
Private Declare Function LPZLGB_INCREMENT Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_DECREMENT)(unsigned char ,long *);
Private Declare Function LPZLGB_DECRENENT Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_WRITEVAL)(unsigned char ,long );
Private Declare Function LPZLGB_WRITEVAL Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_READVAL)(unsigned char ,long *);
Private Declare Function LPZLGB_READVAL Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_CHANGEPWD)(unsigned char ,unsigned char,unsigned char *);
Private Declare Function LPZLGB_CHANGEPWD Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByVal BYT2 As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_RESTORE)(unsigned char );
Private Declare Function LPZLGB_RESTORE Lib "zlg500b.dll" (ByVal bytBuffer As Byte) As Long

'typedef unsigned char (CALLBACK* LPZLGB_TRANSFER)(unsigned char );
Private Declare Function LPZLGB_TRANSFER Lib "zlg500b.dll" (ByVal bytBuffer As Byte) As Long

'typedef unsigned char (CALLBACK* LPZLGB_VALUE)(unsigned char,unsigned char,long *,unsigned char);
Private Declare Function LPZLGB_VALUE Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByVal BYT2 As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_LOAD_KEY)(unsigned char,unsigned char,unsigned char *);
Private Declare Function LPZLGB_LOAD_KEY Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_RESET)(unsigned char);
Private Declare Function LPZLGB_RESET Lib "zlg500b.dll" (ByVal bytBuffer As Byte) As Long

'typedef unsigned char (CALLBACK* LPZLGB_CLOSE)(void);
Private Declare Function LPZLGB_CLOSE Lib "zlg500b.dll" () As Long

'typedef unsigned char (CALLBACK* LPZLGB_CONFIG)(void);
Private Declare Function LPZLGB_CONFIG Lib "zlg500b.dll" () As Long

'typedef unsigned char (CALLBACK* LPZLGB_GET_INFO)(unsigned char *);
Private Declare Function LPZLGB_GET_INFO Lib "zlg500b.dll" (ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_CHECK_WRITE)(unsigned char,unsigned char,unsigned char,unsigned char *);
Private Declare Function LPZLGB_CHECK_WRITE Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByVal bytBuffer2 As Byte, ByVal bytBuffer3 As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_SET_CONTROL_BIT)();
Private Declare Function LPZLGB_SET_CONTROL_BIT Lib "zlg500b.dll" () As Long

'typedef unsigned char (CALLBACK* LPZLGB_CLR_CONTROL_BIT)();
Private Declare Function LPZLGB_CLR_CONTROL_BIT Lib "zlg500b.dll" () As Long

'typedef unsigned char (CALLBACK* LPZLGB_BUZZER)(unsigned char,unsigned char,unsigned char,unsigned char);
Private Declare Function LPZLGB_BUZZER Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByVal bytBuffer2 As Byte, ByVal bytBuffer3 As Byte, ByVal bytBuffer4 As Byte) As Long

'typedef unsigned char (CALLBACK* LPZLGB_READ_E2)(unsigned char,unsigned char ,unsigned char *);
Private Declare Function LPZLGB_READ_E2 Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByVal bytBuffer2 As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK* LPZLGB_WRITE_E2)(unsigned char,unsigned char,unsigned char *);
Private Declare Function LPZLGB_WRITE_E2 Lib "zlg500b.dll" (ByVal bytBuffer As Byte, ByVal bytBuffer2 As Byte, ByRef intBuffer As Integer) As Long

'typedef unsigned char (CALLBACK *LPZLGB_INIT)(int , int );
Private Declare Function LPZLGB_init Lib "zlg500b.dll" (ByVal bytBuffer As Integer, ByVal bytBuffer2 As Integer) As Long

'typedef void (CALLBACK* LPZLGB_EXIT)(void);
Private Declare Function LPZLGB_EXIT Lib "zlg500b.dll" () As Long

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧