Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use these DLL files???

Status
Not open for further replies.

ProblemBuilder

Programmer
Oct 18, 2005
1
CN
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(strCardID:pChar;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;
scardid:pchar;
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!

 
seems like your error is where you define your function...u can try using ref for integer nLen...and u said there are two dll's, maybe its the other dll that contains the api function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top