ProblemBuilder
Programmer
hello
I just have a problem.
I have a device which is used to read IC cards,and there is two DLL files to support this device.They gave me an example,a Delphi programme.
//=====================Delphi========================//
interface
const
DLLNAME='ICRoom.dll';
Function OpenPort(hWnd:integer;strCommDef:string):integer;stdcall;external DLLNAME name 'OpenPort';
Function ClosePort():integer;stdcall;external DLLNAME name 'ClosePort';
Function ConnectDevice(nDevAddr:integer):integer;stdcall;external DLLNAME name 'ConnectDevice';
Function GetErrorMsg(ErrorCode:integer):string;stdcall;external DLLNAME name 'GetErrorMsg';
Function GetCardID(strCardIDChar;var curBalance:double;nLen:integer):integer;stdcall;external DLLNAME name 'GetCardID';
Function ReduceCash(strCardID:string;curAmount:double):integer;stdcall;external DLLNAME name 'ReduceCash';
implementation
end.
var
code:integer;
scardidchar;
cardbalance:double;
begin
getmem(scardid,10);
cardbalance:=0;
code:=GetCardID(scardid,cardbalance,8);
end
//===================================================//
and follow is what I do in PowerBuilder.
//===================PowerBuilder=====================//
function integer OpenPort(integer hWnd,string strCommDef) Library "ICRoom.dll"
function integer ClosePort() Library "ICRoom.dll"
function integer ConnectDevice(integer nDevAddr) Library "ICRoom.dll"
function string GetErrorMsg(integer ErrorCode) Library "ICRoom.dll"
function integer GetCardID(ref string strCardID,double curBalance,integer nLen) Library "ICRoom.dll"
function integer ReduceCash(string strCardID,double curAmount) Library "ICRoom.dll"
integer code
string scardid
double cardbalance
code = GetCardID(ref scardid,cardbalance,8)
if code=1 then
Messagebox('OK!','Card NO?' + string(scardid) + 'CurMoney?'+ string(cardbalance))
else
Messagebox('Failed!',GetErrorMsg(code))
end if
//===================================================//
when my code got to 'code = GetCardID(ref scardid,cardbalance,8)',the programme terminated,and PB gave the error message,
'specified argument type differ from requirer argument type at runtime in dll function getcardid.(invalid stack pointer on return from function call)'
It makes me going craze,help me!
Wating for your reply! thank you so much!
I just have a problem.
I have a device which is used to read IC cards,and there is two DLL files to support this device.They gave me an example,a Delphi programme.
//=====================Delphi========================//
interface
const
DLLNAME='ICRoom.dll';
Function OpenPort(hWnd:integer;strCommDef:string):integer;stdcall;external DLLNAME name 'OpenPort';
Function ClosePort():integer;stdcall;external DLLNAME name 'ClosePort';
Function ConnectDevice(nDevAddr:integer):integer;stdcall;external DLLNAME name 'ConnectDevice';
Function GetErrorMsg(ErrorCode:integer):string;stdcall;external DLLNAME name 'GetErrorMsg';
Function GetCardID(strCardIDChar;var curBalance:double;nLen:integer):integer;stdcall;external DLLNAME name 'GetCardID';
Function ReduceCash(strCardID:string;curAmount:double):integer;stdcall;external DLLNAME name 'ReduceCash';
implementation
end.
var
code:integer;
scardidchar;
cardbalance:double;
begin
getmem(scardid,10);
cardbalance:=0;
code:=GetCardID(scardid,cardbalance,8);
end
//===================================================//
and follow is what I do in PowerBuilder.
//===================PowerBuilder=====================//
function integer OpenPort(integer hWnd,string strCommDef) Library "ICRoom.dll"
function integer ClosePort() Library "ICRoom.dll"
function integer ConnectDevice(integer nDevAddr) Library "ICRoom.dll"
function string GetErrorMsg(integer ErrorCode) Library "ICRoom.dll"
function integer GetCardID(ref string strCardID,double curBalance,integer nLen) Library "ICRoom.dll"
function integer ReduceCash(string strCardID,double curAmount) Library "ICRoom.dll"
integer code
string scardid
double cardbalance
code = GetCardID(ref scardid,cardbalance,8)
if code=1 then
Messagebox('OK!','Card NO?' + string(scardid) + 'CurMoney?'+ string(cardbalance))
else
Messagebox('Failed!',GetErrorMsg(code))
end if
//===================================================//
when my code got to 'code = GetCardID(ref scardid,cardbalance,8)',the programme terminated,and PB gave the error message,
'specified argument type differ from requirer argument type at runtime in dll function getcardid.(invalid stack pointer on return from function call)'
It makes me going craze,help me!
Wating for your reply! thank you so much!