dll文件调用,VB语句改为Delphi语句(20分)

  • 主题发起人 主题发起人 wildhorsetlj
  • 开始时间 开始时间
W

wildhorsetlj

Unregistered / Unconfirmed
GUEST, unregistred user!
Public Type ZT_PCIBOARD
lIndex As Long
hHandle As Long
nCh As Integer
lData As Long
pldata As Long
lCode As Long
End Type

Public Declare Function OpenDevicePlx Lib "pci8kp.dll" (nZT_PCIBOARD As ZT_PCIBOARD) As Long
Public Declare Function CloseDevicePlx Lib "pci8kp.dll" (nZT_PCIBOARD As ZT_PCIBOARD) As Long

上述语句为VB中调用成功的语句,但改写成Delphi语句后程序无法执行,不知道是否是改写错误,请在线的大富翁们能够给以帮助!
 
type
ZT_PCIBORD=record
lIndex :integer;
hHandle :integer;
nCh : Integer
lData : integer;
pldata :integer;
lCode :integer
end;
//
function OpenDevicePlx(nZT_PCIBOARD :ZT_PCIBOARD):integer;stdcall;external 'pci8kp.dll';
 
to feverkim
提示:Undeclared identifier: 'ZT_PCIBOARD'
 
你看你的pci8kp.dll是否为完整路径
 
我改写后的代码如下:
type
ZT_PCIBOARD=Record
lIndex:integer; //PCI卡索引值,该值在安装时被系统分配
hHandle:integer; //PCI卡的操作句柄(只有涉及中断时才用)
nCh:integer; //通道号
lData:integer; //输入输出数据变量
plData:integer; //输入输出数据指针;
lCode:integer; //设备控制码:0 单通道操作;1多通道操作
end;
MyPCIBOARD=ZT_PCIBOARD;

var中定义变量:
TmpPCI:MyPCIBOARD;

在implementation下增加语句:
function OpenDevicePlx(nZT_PCIBOARD :MyPCIBOARD):integer;stdcall;external 'pci8kp.dll';
function CloseDevicePlx(nZT_PCIBOARD:MyPCIBOARD):integer;stdcall; external 'pci8kp.dll';
function ZT8310AI(nZT_PCIBOARD:MyPCIBOARD):integer;stdcall; external 'pci8kp.dll';
function ZT8310Start(nZT_PCIBOARD:MyPCIBOARD):integer;stdcall;external 'pci8kp.dll';

主程序中;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
CloseDevicePlx(TmpPCI);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
TmpPCI.lIndex :=0;
OpenDevicePlx(TmpPCI);
end;

但执行后出现下面的错误提示,不知道是因为什么原因:
---------------------------
Debugger Exception Notification
---------------------------
Project HWDCOM420.exe raised exception class EAccessViolation with message 'Access violation at address 100036C9 in module 'pci8kp.dll'. Read of address 00000000'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------
 
type
TZT_PCIBOARD=Record
lIndex:integer; //PCI卡索引值,该值在安装时被系统分配
hHandle:integer; //PCI卡的操作句柄(只有涉及中断时才用)
nCh:integer; //通道号
lData:integer; //输入输出数据变量
plData:integer; //输入输出数据指针;
lCode:integer; //设备控制码:0 单通道操作;1多通道操作
end;

var中定义变量:
TmpPCI:TZT_PCIBOARD;

在implementation下增加语句:
function OpenDevicePlx(nZT_PCIBOARD :TZT_PCIBOARD):integer;stdcall;external 'pci8kp.dll';
function CloseDevicePlx(nZT_PCIBOARD:TZT_PCIBOARD):integer;stdcall; external 'pci8kp.dll';
function ZT8310AI(nZT_PCIBOARD:TZT_PCIBOARD):integer;stdcall; external 'pci8kp.dll';
function ZT8310Start(nZT_PCIBOARD:TZT_PCIBOARD):integer;stdcall;external 'pci8kp.dll';

主程序中;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
CloseDevicePlx(TmpPCI);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
TmpPCI.lIndex :=0;
OpenDevicePlx(TmpPCI);
end;


///
把PCI8KP.DLL 和你的程序放在一起.kankan
 
还是同样的报错信息
 
把这个DLL给我看看, feverkim@gmail.com
 
已发送,请查收,谢谢了!
 
to zhlfdm
试了:完整的路径名也不行;把dll文件放在程序可执行文件夹下也不行
 
因为是要返回申明结构的数据,所有要用VAR传递,返回数据

function OpenDevicePlx(var nZT_PCIBOARD :TZT_PCIBOARD):integer;stdcall;external 'pci8kp.dll';
function CloseDevicePlx(var nZT_PCIBOARD:TZT_PCIBOARD):integer;stdcall; external 'pci8kp.dll';
function ZT8310AI(var nZT_PCIBOARD:TZT_PCIBOARD):integer;stdcall; external 'pci8kp.dll';
function ZT8310Start(var nZT_PCIBOARD:TZT_PCIBOARD):integer;stdcall;external 'pci8kp.dll';
 
feverkim:
谢谢你!问题解决!以后还是要多多学习了!
 

Similar threads

I
回复
0
查看
780
import
I
D
回复
0
查看
1K
DelphiTeacher的专栏
D
I
回复
0
查看
756
import
I
后退
顶部