有关DLL调用产生的问题(200分)

  • 主题发起人 star0810
  • 开始时间
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.
 
S

sbzldlb

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
SysUtils,
Classes;

implementation
{$R *.res}

function Test(i:integer):integer;stdcall;  
begin
Result := 123456;
end;
exports
 Test;
begin
end.
 
S

SS2000

Unregistered / Unconfirmed
GUEST, unregistred user!
function Test:integer;stdcall;external'TestDll.dll';
这个定义?
function Test(i:integer):integer;stdcall;external'TestDll.dll';
两个定义不一致
DLL和主程序定义一定要一致
 
J

jmh521

Unregistered / Unconfirmed
GUEST, unregistred user!
lu guo..ding
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
675
import
I
顶部