用vb调用一个用delphi写的dll
Private Declare Function test Lib "test.dll" (ByVal hComm As Long, ByVal id As Integer, ByVal a As My_type) As Integer在delphi中My_type的数据结构是
My_type= packed record
M: packed array[0..10] of Char;
V: packed array[0..6] of Char;
end;vb中总指示a的类型不对,请问我应该怎么做?
Private Declare Function test Lib "test.dll" (ByVal hComm As Long, ByVal id As Integer, ByVal a As My_type) As Integer在delphi中My_type的数据结构是
My_type= packed record
M: packed array[0..10] of Char;
V: packed array[0..6] of Char;
end;vb中总指示a的类型不对,请问我应该怎么做?
My_type= packed record
M: packed array[0..10] of Char;
V: packed array[0..6] of Char;
end;对应VB的定义:
Type packed
m As String * 9
v As String * 9
End Type
m As String * 9
v As String * 5
End Type
m As String * 10
v As String * 6
End Type声明要进行修改
m As String * 10
v As String * 6
End Type
Private Declare Function test Lib "test.dll" (ByVal hComm As Long, ByVal id As long, ByVal a As packed) As long
private Type packed
m As String * 10
v As String * 6
End Type
Private Declare Function test Lib "test.dll" (ByVal hComm As Long, ByVal id As long, Byref a As packed) As long
其实这样更合理一些:private Type packed
m(9) As byte
v(5) as byte
End Type
Private Declare Function test Lib "test.dll" (ByVal hComm As Long, ByVal id As long, Byval a As long) As long调用时Byval a As long传入packed型变量的地址(用varptr获得)
http://www.gnu-pascal.de/gpc/packed.html