关于动态连接库(100分)

E

esgeht

Unregistered / Unconfirmed
GUEST, unregistred user!
厂家提供了一个设备驱动的动态连接库
我在VB下调用该动态连接库的函数可以正常的驱动和操作设备
而我在DELPHI却无法驱动和操作设备了,不知道为什么!!请教!!
在VB下是这样申明的
Declare Function ZmjInit Lib "zmjdll" (ByVal nComm As Long, ByVal nSpeed As Long) As Long
Declare Function ZmjClose Lib "zmjdll" () As Long
Declare Function ZmjCommondBegin Lib "zmjdll" (ByVal byStartAddress As Byte, ByVal byEndAddress As Byte) As Long
Declare Function ZmjCommondEnd Lib "zmjdll" () As Long
Declare Function ZmjTextWindow Lib "zmjdll" (myFontType As ZmjFontType, myFontStyle As ZmjFontStyle, ByVal lpszText As String, myZmjWindow As ZmjWindow) As Long
我在DELPHI下调用的申明如下:
Function ZmjInit(nComm:integer;nSpeed:integer):integer;stdcall;external 'zmjdll.dll';
Function ZmjClose():integer;stdcall;external 'zmjdll.dll';
Function ZmjCommondBegin(byStartAddress:Byte;byEndAddress:Byte):integer;stdcall;external 'zmjdll.dll';
Function ZmjCommondEnd():integer;stdcall;external 'zmjdll.dll';
Function ZmjTextWindow(myFontType:ZmjFontType;myFontStyle:ZmjFontStyle;lpszText:String;myZmjWindow:ZmjWindow):integer;stdcall;external 'zmjdll.dll';
究竟是怎么回事啊?
 
long 改为longint
string 改为 pchar
ZmjFontType要提前定义吧
 
还是不行
long转换成integer没问题的,integer默认的就是longint
 
关键是这个
Function ZmjTextWindow(myFontType:ZmjFontType;myFontStyle:ZmjFontStyle;lpszText:String;myZmjWindow:ZmjWindow):integer;stdcall;external 'zmjdll.dll';
现在那两个参数还不知道是什么样的, String好像也应该改为PChar
 
那几个数据类型在VB中是这样定义的
Type ZmjFontType
byFontType As Byte '字体 01: 6*7点阵英文 02:16点阵汉字 03:24点阵汉字
byFontSpace As Byte '字间距 0---128
byColor As Byte '字体颜色 双色字幕机 0:黑 1:红 2:绿 3:黄 单色字幕机 0: 黑 1: 红 2: 黑 3: 红
byMode As Byte '出字方式 1 --- 18(参见表一)
byRate As Byte '出字速度 0 - --9
byFormat As Byte '对齐方式 1. 居左上显示 2. 居左上显示 3. 居右上显示
End Type
Type ZmjFontStyle
byReverse As Byte '是否反相 0:不反相 1:反相
byBiLines As Byte '是否双线体 0:普通 1:双线体
byWidthScale As Byte '水平放大倍数 1---9
End Type
Type ZmjWindow
wLeft As Integer '左上角x坐标
wTop As Integer '左上角y坐标
wRight As Integer '右下角x坐标
wBottom As Integer '右下角y坐标
End Type

我在DELPHI中这样定义
type
ZmjFontType = record
byFontType:Byte; //字体 01: 6*7点阵英文 02:16点阵汉字 03:24点阵汉字
byFontSpace:Byte; //字间距 0---128
byColor:Byte; //字体颜色 双色字幕机 0:黑 1:红 2:绿 3:黄 单色字幕机 0: 黑 1: 红 2: 黑 3: 红
byMode:Byte; //出字方式 1 --- 18(参见表一)
byRate:Byte; //出字速度 0 - --9
byFormat:Byte; //对齐方式 1. 居左上显示 2. 居左上显示 3. 居右上显示
End;
ZmjFontStyle =record
byReverse:Byte; //是否反相 0:不反相 1:反相
byBiLines:Byte; //是否双线体 0:普通 1:双线体
byWidthScale:Byte; //水平放大倍数 1---9
End;
ZmjWindow = record
wLeft:integer; //左上角x坐标
wTop:integer; //左上角y坐标
wRight:integer; //右下角x坐标
wBottom:integer; //右下角y坐标
End;
 
由于对于VB结构类型的对齐方式不清楚, 所以只能瞎猜了. 你把
record 换成 packed record 试试,看看行不行。
 
多人接受答案了。
 
顶部