delphi中一个值得大家来考虑的DLL问题
所属分类:
软件编程 / Delphi
阅读数:
118
收藏 0赞 0分享
以下是我的原代码:
==========================================================================================
DPR 单元代码
program Mdiform;
uses
Forms,
UMdiform in ´UMdiform.pas´ {Mainform},
UDM in ´UDM.pas´ {GlobalDM: TDataModule},
UFun in ´UFun.pas´;
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TMainform, Mainform);
Application.Run;
end.
===============================================================================================
主窗体代码:
unit UMdiform;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Udm,StdCtrls;
type
TMainform = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
MyHandle:HWND;
{ Public declarations }
end;
var
Mainform: TMainform;
type
T_ShowTestMng=function (var adm:TMainform) : Boolean; StdCall;
implementation
{$R *.dfm}
procedure TMainform.Button1Click(Sender: TObject);
var
Lib_ :THandle;
_ShowTestMng :T_ShowTestMng;
begin
Lib_:=LoadLibrary(pchar(´MdiChild.dll´));
try
@_ShowTestMng:=GetProcAddress(Lib_,´_ShowTestMng´);
if not(@_ShowTestMng=nil) then
_ShowTestMng(Mainform);
finally
FreeLibrary(Lib_);
end;
end;
procedure TMainform.FormCreate(Sender: TObject);
begin
MyHandle:=Application.Handle;
end;
end.
==============================================================================================
子窗体DLL代码:
library MdiChild;
uses
ShareMem,
UMdiform, //此单元为父窗体单元,在顶目设置中我已经设置了搜索此单元在路径。
Forms,
SysUtils,
Classes,
UChild in ´UChild.pas´ {FrmChild};//FrmChild子窗体的FormStyle属性为FsMDIChild
{$R *.res}
function _ShowTestMng(var adm:TMainform) : Boolean; StdCall;
begin
result:=true;
Application.Handle:=adm.MyHandle;
Application.CreateForm(TFrmChild,FrmChild); //程序就出错在此:出错原因是:Cannot create form. No MDI Forms are currently active.
FrmChild.Show;
end;
exports
_ShowTestMng;
end.
Delphi基本图像处理方法汇总
这篇文章主要介绍了Delphi基本图像处理方法,实例汇总了Delphi操作图像实现浮雕、反色、模糊、翻转等常用效果的方法,非常具有实用价值,需要的朋友可以参考下
收藏 0赞 0分享
delphi制作wav文件的方法
这篇文章主要介绍了delphi制作wav文件的方法,涉及Delphi操作多媒体文件的相关技巧,需要的朋友可以参考下
收藏 0赞 0分享
Delphi提取PDF文本实例
下面小编就为大家带来一篇Delphi提取PDF文本实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
收藏 0赞 0分享
Delphi 用DLL实现插件的简单实例
这篇文章主要介绍了Delphi 用DLL实现插件的简单实例的相关资料,希望通过本文能帮助到大家,这里提供实例帮助大家掌握这部分内容,需要的朋友可以参考下
收藏 0赞 0分享
查看更多