Z
zhuye1
Unregistered / Unconfirmed
GUEST, unregistred user!
在主程序里放一个 SkinData1,在主程序里调用 DLL 里的 MDI窗体,现在的问题是,能够正常显示,但是在主程序退出的时候报内存错误
unit Unit111;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,WinSkinData,winskindlg,winskinform;
type
TForm1 = class(TForm)
Button1: TButton;
SkinData1: TSkinData;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TShowFunc = procedure(App:TApplication);stdcall;
TSkinDll = procedure(ahandle: HWnd;adata: Pointer);stdcall;
var
Form1: TForm1;
showfm,hidefm:TshowFunc;
SetApp:Tskindll;
lib:Thandle;
implementation
{$R *.dfm}
procedure LoadDLL;
begin
Lib := LoadLibrary('Project2.dll');
if lib<>0 then
begin
@Showfm := GetProcAddress(Lib,'ShowDLLForm');
@setApp := GetProcAddress(Lib,'SetApplicationHandle');
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if lib=0 then
begin
loaddll;
SetApp(Application.Handle,winskindlg.skinmanager);
end;
if @showfm<>nil then
Showfm(Application);
end;
end.
这个是主程序测试的代码,代码没有错误,SetApplicationHandle 是DLL里提供的一个 接口函数
procedure SetApplicationHandle(Handle: HWnd;adata: Pointer);
begin
Application.Handle := Handle;
Winskindata.SkinDll(adata);
end;
unit Unit111;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,WinSkinData,winskindlg,winskinform;
type
TForm1 = class(TForm)
Button1: TButton;
SkinData1: TSkinData;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TShowFunc = procedure(App:TApplication);stdcall;
TSkinDll = procedure(ahandle: HWnd;adata: Pointer);stdcall;
var
Form1: TForm1;
showfm,hidefm:TshowFunc;
SetApp:Tskindll;
lib:Thandle;
implementation
{$R *.dfm}
procedure LoadDLL;
begin
Lib := LoadLibrary('Project2.dll');
if lib<>0 then
begin
@Showfm := GetProcAddress(Lib,'ShowDLLForm');
@setApp := GetProcAddress(Lib,'SetApplicationHandle');
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if lib=0 then
begin
loaddll;
SetApp(Application.Handle,winskindlg.skinmanager);
end;
if @showfm<>nil then
Showfm(Application);
end;
end.
这个是主程序测试的代码,代码没有错误,SetApplicationHandle 是DLL里提供的一个 接口函数
procedure SetApplicationHandle(Handle: HWnd;adata: Pointer);
begin
Application.Handle := Handle;
Winskindata.SkinDll(adata);
end;