D
delphi5988
Unregistered / Unconfirmed
GUEST, unregistred user!
1/不知为什么,怎么不管是动态引入还是静态引入,这个DLL的内存用完全就是不能释放
大家说说,这是怎么处理,内存问题的,因为我的软件要常驻内存,所以,占内存很多,
我想用动态引入DLL,用完全再 释放内存。请帮帮我!
2/这个如果把多线程写入DLL中怎么结束多线程这是一个问题.
各位兄弟帮帮我!谢谢
library Project2;
uses
SysUtils,
Classes,StdCtrls;
{$R *.res}
procedure showme(listbox:Tlistbox);stdcall;
var
i:integer;
begin
for i:=0 to 20000 do
begin
listbox.Items.Add(intTostr(i));
end;
end;
exports
showme;
begin
end.
---------------------下面是UNIT单元文件
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
ListBox1: TListBox;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Tshowme=procedure(listbox:Tlistbox);stdcall;
var
Form1: TForm1;
implementation
procedure TForm1.Button2Click(Sender: TObject);
var
ww:tshowme;
a:Thandle;
begin
a:=loadlibrary('project2.dll');
try
if a<>0 then
begin
@ww:=GetProcAddress(a,'showme');
ww(form1.ListBox1);
end;
finally
FreeLibrary(a);
end;
end;
大家说说,这是怎么处理,内存问题的,因为我的软件要常驻内存,所以,占内存很多,
我想用动态引入DLL,用完全再 释放内存。请帮帮我!
2/这个如果把多线程写入DLL中怎么结束多线程这是一个问题.
各位兄弟帮帮我!谢谢
library Project2;
uses
SysUtils,
Classes,StdCtrls;
{$R *.res}
procedure showme(listbox:Tlistbox);stdcall;
var
i:integer;
begin
for i:=0 to 20000 do
begin
listbox.Items.Add(intTostr(i));
end;
end;
exports
showme;
begin
end.
---------------------下面是UNIT单元文件
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
ListBox1: TListBox;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Tshowme=procedure(listbox:Tlistbox);stdcall;
var
Form1: TForm1;
implementation
procedure TForm1.Button2Click(Sender: TObject);
var
ww:tshowme;
a:Thandle;
begin
a:=loadlibrary('project2.dll');
try
if a<>0 then
begin
@ww:=GetProcAddress(a,'showme');
ww(form1.ListBox1);
end;
finally
FreeLibrary(a);
end;
end;