D
delphi5988
Unregistered / Unconfirmed
GUEST, unregistred user!
我想把LISTBOX控件的一个变量写到DLL中原后调用,可不知错在那儿,请帮帮我呀,兄弟们
这是代码
可以通过下例代码就是用FORM调用时提示错误,我怀疑还是DLL有问题
//--------------------------------------------------
library Project1;
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas';
{$R *.res}
exports
mm;
begin
end.
//----------------UNIT1部分------------------------------------
unit Unit1;
interface
uses
StdCtrls,SysUtils;
procedure mm(listbox:Tlistbox);export;
implementation
procedure mm(listbox:Tlistbox);
var
i:integer;
begin
for i:=0 to 1245 do
begin
listbox.Items.Add(inttostr(i));
end;
end;
end.
//-------------- FORM调用部分--------------------------------------------
myunit
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
procedure mm(listbox:Tlistbox);stdcall;external'project1.dll' name 'mm';
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
mm(form2.ListBox1);
end;
end.
这是代码
可以通过下例代码就是用FORM调用时提示错误,我怀疑还是DLL有问题
//--------------------------------------------------
library Project1;
uses
SysUtils,
Classes,
Unit1 in 'Unit1.pas';
{$R *.res}
exports
mm;
begin
end.
//----------------UNIT1部分------------------------------------
unit Unit1;
interface
uses
StdCtrls,SysUtils;
procedure mm(listbox:Tlistbox);export;
implementation
procedure mm(listbox:Tlistbox);
var
i:integer;
begin
for i:=0 to 1245 do
begin
listbox.Items.Add(inttostr(i));
end;
end;
end.
//-------------- FORM调用部分--------------------------------------------
myunit
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
procedure mm(listbox:Tlistbox);stdcall;external'project1.dll' name 'mm';
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
mm(form2.ListBox1);
end;
end.