高分求教高手,Dll文件的使用
haj77 2003-05-13 02:53:50 由于我对VB刚开始认识,现在有C++Build写的一个DLL文件,里面有两个函数:
extern "C" __declspec(dllimport) int __stdcall MF_Request(int DeviceAddress, unsigned char inf_mode, unsigned char *buffer);
extern "C" __declspec(dllimport) int __stdcall MF_Anticoll(int DeviceAddress,unsigned char *snr,unsigned char &status);
1.在Delphi上定义为:
function MF_Request(addr:integer;mode:byte;atq:pchar):integer;stdcall;external 'CVAPIV01.dll'
function MF_Anticoll(addr:integer;snr:pchar;cstatus:pchar):integer;stdcall;external 'CVAPIV01.dll';
使用为:
var ATQ:String;
SetLength(ATQ,2);
IF MF_Request(0,1,Pchar(ATQ))=0 then
Showmessage(调用成功);
上面是OK的。
2.请问在VB中如何定义调用它,需要注册那么麻烦吗?我下面写的3个参数对吗?
Private Declare Function MF_Request Lib "CVAPIV01.dll" (ByVal DeviceAddress As Long, ByVal mode As Long, ByVal buffer As String)
As Integer
Private Declare Function MF_Anticoll Lib "CVAPIV01.dll" (ByVal DeviceAddress As Long, ByVal snr As string, ByVal buffer As String)
As Integer
3.如果不对如何定义以及在语句中的使用?