我新建了一个application,在form内添加一个button控件,在button的onclick事件中调用SafeEngine.dll中的SEH_InitialSession过程,可是运行时会报如下错误:Access violation at address 1000C8B1 in module 'SafeEngine.dll'.Write of address 00000002.请问主要是哪方面出错啦? 我的源码如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls; procedure SEH_InitialSession(PriKeyDevType: Integer; const strPrivKeyDevParam: WideString;const strPriKeyPass: WideString; lPriKeyTimeout: Integer;CertChainDevType: Integer; const
strCertChainDevParam: WideString;const strCertChainPass:
WideString);StdCall;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
procedure SEH_InitialSession;external 'SafeEngine.dll' name 'SEH_InitialSession';
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
SEH_InitialSession(2,'userkey.key','sheca',1000,2,'CertChain.spc','');
end;end.
解决方案 »
- 线程、内存泄露问题 顺便过年散分
- 初学delphi 看见书上讲8位16位32位有无符号数,什么叫位?跟字节有关系吗?
- RecordCount 为什么是-1??
- DELPHI7???
- 请问如何在Access里面如何定义BLOB字段,是定义OLE对象吗?为什么不能够指定BLOB的大小?回答了对了立即就给分!!!!
- 生成SQL语句的奇怪问题:单引号(')居然变成了问号了(?)!!!
- [提问]Delphi中是否可以像.Net中的Process.Exited一样捕获指定进程的退出事件?
- combobox 列表向上显示,有办法吗?
- 被同公司的女孩爱上了,干不了,怎么办 ????
- 关于API函数的问题
- 怎样在一个Form关闭前弹出对话框
- 学习GIS的高手请进
并在输出声明前加 external "C"
在调用以下函数前必须先调用此函数初始化.
功能:初始化环境,从设备中读取私钥、根证书。
语法:int SEH_InitialSession(unsigned short privatekeydevicetype, char *privatekeydeviceparameter, char *privatekeypassword, unsigned long privatekeytimeout, unsigned short rootcertdevicetype, char *rootcertdeviceparameter, char *rootcertpassword )是不是我用的参数类型不对呀?能否给出完整的函数定义段,在onclick事件中
原先的SEH_InitialSession(2,'userkey.key','sheca',1000,2,'CertChain.spc','')又要怎样改呀?另to dw601211:按照你的方法,我这段程序要做哪些修改呀?请指教
implementation;
function SEH_InitialSession(PriKeyDevType: Integer; const strPrivKeyDevParam: WideString;const strPriKeyPass: WideString; lPriKeyTimeout: Integer;CertChainDevType: Integer; const
strCertChainDevParam: WideString;const strCertChainPass:
WideString):integer;decall;external 'SafeEngine.dll' ;‘;decall;external 'SafeEngine.dll' ;’该不分好象有点问题,你在调试一下
2、但使用stdcall还是decall就看说明书和Demo吧,调用普通的API使用stdcall;
3、你函数的声明有问题。你看看说明书,凡是原函数定义为char *的地方一律使用PChar类型代替,举例如下:假设函数f需要PChar类型的参数
var
s: String;
ws: WideString;
begin
f(PChar(s));
f(PChar(String(ws)));
end;