S
star0810
Unregistered / Unconfirmed
GUEST, unregistred user!
环境:delphi10+windows2003sever
使用dll向程序传递参数
参数可以成功传递,但是主程序却报错,
错误信息如下:
assertion failure
index<=items.n() in../win32src/dbkimpl.cpp at line 2661
continue execution?
附dll和主程序代码
DLL
library TestDll;
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas';
{$R *.res}
exports
Test;
begin
end.
unit Unit1;
interface
uses
SysUtils,
Classes;
function Test(i:integer):integer;export;stdcall;
implementation
function Test(i:integer):integer;
begin
Result := 123456;
end;
end.
主程序
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm8 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
function Test:integer;stdcall;external'TestDll.dll';
procedure TForm8.Button1Click(Sender: TObject);
begin
showmessage(inttostr(Test));
end;
end.
使用dll向程序传递参数
参数可以成功传递,但是主程序却报错,
错误信息如下:
assertion failure
index<=items.n() in../win32src/dbkimpl.cpp at line 2661
continue execution?
附dll和主程序代码
DLL
library TestDll;
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas';
{$R *.res}
exports
Test;
begin
end.
unit Unit1;
interface
uses
SysUtils,
Classes;
function Test(i:integer):integer;export;stdcall;
implementation
function Test(i:integer):integer;
begin
Result := 123456;
end;
end.
主程序
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm8 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
function Test:integer;stdcall;external'TestDll.dll';
procedure TForm8.Button1Click(Sender: TObject);
begin
showmessage(inttostr(Test));
end;
end.