Dll调用问题??大家进来看看

Sunniness 2005-01-28 05:43:48
请教一个问题。我用Delphi调用Vc的动态库。在Vc动态库里有一个

int __stdcall InitKey( int com );

语句,我调用它怎么内存出错?

我是这样调用的:
function InitKey(In_Com: Shortint): Shortint; overload; far;External 'KCCardInf.dll'

LabEdt_COMValue.Text := IntToStr(InitKey(1));
...全文
235 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sunniness 2005-01-31
  • 打赏
  • 举报
回复
我把电脑重新启动一下,就可以的
,谢谢各位
halfdream 2005-01-31
  • 打赏
  • 举报
回复
这个错误很明显应该不是那三行代码里面的吧。。。。

楼主细心些吧。
Sunniness 2005-01-31
  • 打赏
  • 举报
回复
var
ErrorMsg: array[0..1000]of char;
ErrorCode: integer;
// ErrorMsg: PChar;
begin
ErrorCode := StrToInt(LabEdt_ErrorCode.Text);
FillChar(ErrorMsg, 1000, 0);
GetErrInfo(ErrorCode, @ErrorMsg);
end;
这段代码怎么出这样的错误:
[Error] Uni_ReadCard.pas(154): Types of actual and formal var parameters must be identical
halfdream 2005-01-31
  • 打赏
  • 举报
回复
char* __stdcall GetErrInfo( int errCode, char* errInfo );
可以转换成
function GetErrInfo(errCode:Integer;errInfo:PChar):PChar;

严格说,这个函数定义得很不严谨, 呵呵..会让人觉得这公司缺人才..

------------------------------------------------


调用:
var
buf:array[0..1000]of char;

....
FillChar(buf,1000,0);

GetErrInfo(errCode,@buf);





Sunniness 2005-01-31
  • 打赏
  • 举报
回复

////////////////////////////////////////////////////////////////////////////////////////////
// 功能: 获取详细的错误信息
// 输入参数:
// errCode 函数调用时返回的错误代码
// 返回值: 成功 -- 详细的错误信息
// 失败 -- NULL
////////////////////////////////////////////////////////////////////////////////////////////
char* __stdcall GetErrInfo( int errCode, char* errInfo );

delphi调用怎么出错!???
function GetErrInfo(ErrCode: Integer; var ErrInfo: PChar): PChar;
far; stdcall; external 'KCCardInf.dll';
这个函数还是出错??
Sunniness 2005-01-29
  • 打赏
  • 举报
回复
////////////////////////////////////////////////////////////////////////////////////////////
// 功能: 获取详细的错误信息
// 输入参数:
// errCode 函数调用时返回的错误代码
// 返回值: 成功 -- 详细的错误信息
// 失败 -- NULL
////////////////////////////////////////////////////////////////////////////////////////////
char* __stdcall GetErrInfo( int errCode, char* errInfo );


我在delphi 里怎样调用VC的这个涵数;
hanwen 2005-01-29
  • 打赏
  • 举报
回复
mark
Sunniness 2005-01-29
  • 打赏
  • 举报
回复
找不到:mwrf32.dll,这个动态连接库是系统的还是应用程序的啊!?
halfdream 2005-01-29
  • 打赏
  • 举报
回复
MWRF32.DLL应该是你用那些卡设备带的接口程序吧.
估计是这儿出的.
http://www.gzmwiccard.com



function GetMainPurseInfo(com:Integer;
var IccID:Cardinal;
userName:Pchar;
var balance:Integer;
var amount:short;
var exchangeSn:short):Integer;stdcall;
Kevin_Lmx 2005-01-29
  • 打赏
  • 举报
回复
function GetMainPurseInfo(com :Integer;IccID:PULONG;userName:PByte;balace:PLongint;amount:PShortint;exchangeSn:PShortint):Integer;stdcall;
Sunniness 2005-01-29
  • 打赏
  • 举报
回复
up
Sunniness 2005-01-29
  • 打赏
  • 举报
回复
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// 功能: 取得主钱包的信息
// 输入参数:
// com 串口号 0:com1, 1:com2, 2:com3 ...
// 返回参数:
// IccID IC卡帐号
// userName 用户姓名
// balance 卡片余额
// amount 最后一次消费金额
// exchangeSn 卡片交易流水号
// 返回值:
// 0 成功
// 非0 失败(调用GetErrInfo可以获得详细的错误信息)
//////////////////////////////////////////////////////////////////////////////////////////////////////////
int __stdcall GetMainPurseInfo( int com, unsigned long* IccID, BYTE* userName, long* balance, short* amount, short* exchangeSn );

我在delphi 里怎样调用VC的这个涵数;
halfdream 2005-01-29
  • 打赏
  • 举报
回复
DELPHI对应那函数声明要改两处.
1,加stdcall声明
2,Shortint改成Integer
herman~~ 2005-01-28
  • 打赏
  • 举报
回复
调用的方法好象没错
Kshape_zh 2005-01-28
  • 打赏
  • 举报
回复
你应该说报什么错误啊!
大哥

要不你把shortint改成integer看看
jb99334 2005-01-28
  • 打赏
  • 举报
回复
具体方法参考
http://www.programfan.com/showarticle.asp?id=1211
gwolf 2005-01-28
  • 打赏
  • 举报
回复
报啥错

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧