同上
解决方案 »
- C++dll delphi静态调用 单独一个unsigned?
- 怎样才能找出下面表中A字段靠3最近的记录(如果有小于等于的取最小的 否则取大于的),定SQL语句
- 喜欢昆工一MM,表白了但她没有说什么。。。散分一
- 请教一个有关"Banker's Rounding"的问题。
- 怎么让两个窗体同时启动?就像flash等软件界面那样
- 怎样在两个DBEDIT控件中将TAB在在两控件中的移动换成ENTER?
- 有关LISTVIEW的问题。
- 这个问题没有人能够准确回答,真正的Delphi高手请进:
- 由于使用了字典表,数据库里的记录能否在DBGIRD中显示时自动转换??有点头疼啊
- 各位,理解错我的意思了,我需要在B/S结构下的客户端程序存取服务器端的文件!
- 如何实现多个窗口在不同的显示器中显示
- Indy 的 IDTcpServer 无缘无故断开客户端
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TFrameClass = class of TFrame;
//注意 必须是class of TFrame而不是 class(TFrame)
//class of TFrame 声明的是类类型 f:TFrameClass是一个类
//class(TFrame) 是声明一个类, 这个类继承了TFrame类 f: TFrame; 是一个对象
TGetDllFrameClass = function (App:THandle;frm:THandle):TFrameClass;stdcall;
TGetDllFormClass = function (App:THandle;frm:THandle):TFormClass;stdcall;
type
TForm1 = class(TForm)
btn1: TButton;
pnl1: TPanel;
btn2: TButton;
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
private
DLLHandle: THandle;
GetDllFrameClass: TGetDllFrameClass;
GetDllFormClass: TGetDllFormClass;
public
{ Public declarations }
end;var
Form1: TForm1;implementation
var
TMP:TFrameClass;
tmp2:TFrame;
TMP3:TFormClass;
tmp4:TForm;
{$R *.dfm}procedure TForm1.btn1Click(Sender: TObject);
begin
DLLHandle := LoadLibrary('DLL.dll');
try
@GetDllFrameClass := GetProcAddress(DLLHandle, 'GetDllFrameClass');
if @GetDllFrameClass = nil then
Abort;
tmp:=GetDllFrameClass(application.Handle,Self.Handle);
tmp2:=TMP.Create(self);
tmp2.Parent:=pnl1;
tmp2.Show;
except
raise;
end;
end; //这是调用dll里的frame类procedure TForm1.btn2Click(Sender: TObject);
begin
DLLHandle := LoadLibrary('DLL.dll');
try
@GetDllFormClass := GetProcAddress(DLLHandle, 'GetDllFormClass');
if @GetDllFormClass = nil then
Abort;
tmp3:=GetDllFormClass(application.Handle,Self.Handle);
Application.CreateForm(tmp3,tmp4);
tmp4.Show;
except
raise;
end;
end;end.
下面是DLL里的源码:library Dll;{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }uses
SysUtils,
Classes,
Unit2 in 'Unit2.pas' {Frame1: TFrame},
Unit1 in 'Unit1.pas' {Form1};{$R *.res}
exports GetDllFrameClass,GetDllFormClass;begin
end.下面是dll引用的窗体源码:unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TFrame1 = class(TFrame)
btn1: TButton;
mmo1: TMemo;
lbl1: TLabel;
scrlbr1: TScrollBar;
private
{ Private declarations }
public
{ Public declarations }
end;
TFrameClass = class of TFrame ;
function GetDllFrameClass(App:THandle;frm:THandle):TFrameClass;stdcall;
implementation{$R *.dfm}
function GetDllFrameClass(App:THandle;frm:THandle):TFrameClass;stdcall;
begin
//传进来的参数原来是为了和主程序沟通,不是必要的,这里就不管它了
Result:=TFrame1;
end;
end.