DLL调用很奇怪的问题,求教!
我一个项目中有读食堂用的售饭机,DELPHI中调用成功,而PowerBuilder 9.0中调用不成功,求教。情况如下:
delphi中申明如下:
function SetConnectInfo(IConnectType:Integer;InPort:Integer; ITcpAddress:string;InBaud:Integer):Boolean; stdcall;far external DllName name '_SetConnectInfo@16';
function GetName(nDevice:Byte;Name:PChar;Version:PChar):Boolean; stdcall;far external DllName name '_GetName@12';
delphi中调用如下:
Name,Version:PChar;
SetConnectInfo(0,3,'',38400);
GetName(StrToInt(edt25.Text),Name,Version);
调用成功
我在PB中申明如下:
Public Function boolean SetConnectInfo(int IConnectType,int InPort,string ITcpAddress,int InBaud) LIBRARY "ICXF.dll" ALIAS FOR "_SetConnectInfo@16"
Public Function boolean GetName(char nDevice,ref char Name[],ref char Version[]) LIBRARY "ICXF.dll" ALIAS FOR "_GetName@12"
GetName函数中的nDevice分别试了int、char,Name、Version分别试了 ref char[]、ref string都不行。
SetConnectInfo调用成功
GetName 的调用试了好多种方式都失败
SetConnectInfo(0,3,'',38400) 成功
char name[],Version[]
for i=1 to 30
name[i]=char(0)
version[i]=char(0)
next
//机号:1
aa='1'
if GetName('1',Name[],Version[]) then
messagebox("",Name)
else
messagebox("系统提示","GetRecord失败!")
end if
或
string name,Version
name=space(30)
version=space(30)
aa='1'
if GetName(1,Name,Version) then
messagebox("",Name)
else
messagebox("系统提示","GetRecord失败!")
end if