delphi调用SCardEstablishContext,编译没报错,执行的时候报错

weixin_40010593 2018-02-08 10:10:03
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
function SCardEstablishContext(dwScope:LongInt;pvReserved1:Pointer;pvReserved2:Pointer;phContext:Thandle):LongInt;stdcall;external'WinSCard.dll';

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var
ret:LongInt;
hSC:Thandle;

begin
ret := SCardEstablishContext(0,nil,nil,hSC);
if ret <> 0 then
Edit1.Text:='false'
else
Edit1.Text:='true';
end;

end.
报错信息
‘Access violation at address 0042F838 in module 'Project1.exe',read of address CD00FFEC ’

再有顺便问一下想拿delphi做一个读M1卡的程序,使用Smart card相关函数能实现吗?



...全文
1375 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
pkdebug 2018-02-10
  • 打赏
  • 举报
回复
Handle没有值直接用吗?
weixin_40010593 2018-02-08
  • 打赏
  • 举报
回复
挺急的,我是小白,还望大神指导

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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