library UDllFrom; //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,
forms,
RzTabs,
UChildForm in 'UChildForm.pas' {Form1};{$R *.res}
procedure AddTabSheet(FormClass: TFormClass;tbs:TRZTabSheet; rzpgc:TRZPagecontrol);
var
Form:TForm;
begin
rzpgc.ActivePage := tbs; //加上这一步算是双向指定了,指定激活页
Form := FormClass.Create(tbs); //创建Form(用TabSheet)实例
Form.Parent := tbs; //指定Form的父窗体
tbs.Caption := Form.Caption; //标题
tbs.TabVisible:=True;
Form.Show; //显示
end;
function run_form(hs:THandle;tbs:TRZTabSheet;rzpgc:TRZPagecontrol):integer;stdcall;
var
TForm1:TFormclass;
begin
Application.Handle:=hs;
AddTabSheet(TForm1,tbs,rzpgc);
end;
exports
run_form;
begin
end.
-----------------------------調用DLL窗體,將子窗体装入主窗体中
unit UTestForm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RzTabs, StdCtrls, Buttons;type
TTestForm = class(TForm)
rzpgc: TRzPageControl;
tbs: TRzTabSheet;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function rum_Form(hs:THandle;tbs:TRZTabSheet;rzpgc:TRZPagecontrol):Integer;stdcall;external 'UDllFrom.dll';
var
TestForm: TTestForm;implementation{$R *.dfm}procedure TTestForm.BitBtn1Click(Sender: TObject);
begin
rum_Form(Application.Handle,tbs,rzpgc);
end;end.
----------------------------
提示錯誤,無法找到程序的輸入點
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,
forms,
RzTabs,
UChildForm in 'UChildForm.pas' {Form1};{$R *.res}
procedure AddTabSheet(FormClass: TFormClass;tbs:TRZTabSheet; rzpgc:TRZPagecontrol);
var
Form:TForm;
begin
rzpgc.ActivePage := tbs; //加上这一步算是双向指定了,指定激活页
Form := FormClass.Create(tbs); //创建Form(用TabSheet)实例
Form.Parent := tbs; //指定Form的父窗体
tbs.Caption := Form.Caption; //标题
tbs.TabVisible:=True;
Form.Show; //显示
end;
function run_form(hs:THandle;tbs:TRZTabSheet;rzpgc:TRZPagecontrol):integer;stdcall;
var
TForm1:TFormclass;
begin
Application.Handle:=hs;
AddTabSheet(TForm1,tbs,rzpgc);
end;
exports
run_form;
begin
end.
-----------------------------調用DLL窗體,將子窗体装入主窗体中
unit UTestForm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RzTabs, StdCtrls, Buttons;type
TTestForm = class(TForm)
rzpgc: TRzPageControl;
tbs: TRzTabSheet;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function rum_Form(hs:THandle;tbs:TRZTabSheet;rzpgc:TRZPagecontrol):Integer;stdcall;external 'UDllFrom.dll';
var
TestForm: TTestForm;implementation{$R *.dfm}procedure TTestForm.BitBtn1Click(Sender: TObject);
begin
rum_Form(Application.Handle,tbs,rzpgc);
end;end.
----------------------------
提示錯誤,無法找到程序的輸入點
解决方案 »
- TListView的使用
- TADODATASET的FILTER的问题!!
- 使用.net开发的WebService,DELPHI应该如何使用?
- 如何将一个函数地址赋给一个函数指针?
- 超难的存储过程,挑战高手。
- ★★★★★ 散分!!!!★★★★★
- 请问这样的日志文件读写如何进行???~ 在线等待,解决了立刻给分!
- 在stringgrid里不用鼠标点怎么样移动到下一个单元格
- 我用quickreport进行打印编程,在打印预览只能够显示一条记录,怎么回事
- 一个小问题
- 散分delphi7中TcpServer1Accept如何接收缓冲区数据,一天26小时在线等
- 请教一个webbrowser控件自动填表的问题
SysUtils,
Classes,
Controls,
Forms,
Windows,
Unit2 in 'Unit2.pas' {Form2};{$R *.res}
procedure ShowForm(app:TApplication; parent:TWinControl);stdcall;
var
frm : TForm2;
begin
frm := TForm2.Create(Application);
frm.ParentWindow := parent.Handle;
frm.Show;
frm.Align := alClient;
end;exports
ShowForm name 'ShowForm';beginend.
程序调用unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, ExtCtrls,ShellAPI;type
TForm1 = class(TForm)
PageControl1: TPageControl;
Button1: TButton;
TabSheet1: TTabSheet;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationprocedure ShowForm(app:TApplication; parent:TWinControl);stdcall;external 'Project1.dll';{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
ShowForm(Application,PageControl1.Pages[0]);
end;end.
Runtime Error216 at 004F509E
请将实例留在 dll 中。
Form2 在 dll 中创建,在 dll 中释放。
用简单的两个函数对应这两个动作,由exe调用执行。
SysUtils,
Classes,
Controls,
Forms,
Windows,
Unit2 in 'Unit2.pas' {Form2};{$R *.res}
var
DllApp:TApplication;
procedure ShowForm(app:TApplication; parent:TWinControl);stdcall;
var
frm : TForm2;
begin
Application := app;
frm := TForm2.Create(Application);
frm.ParentWindow := parent.Handle;
frm.Show;
frm.Align := alClient;
end;procedure DLLMain(Reason: Integer); register;
begin
{DLL取消调用时,发送DLL_PROCESS_DETACH消息,此时将DLL的Application返回为本身}
if Reason = DLL_PROCESS_DETACH then Application:=DLLApp;
end;exports
ShowForm name 'ShowForm';begin
DllApp := Application;
DLLProc := @DLLMain;
end.
library UDllFrom;{ 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,
forms,
Dialogs,
controls,
windows,
UChildForm in 'UChildForm.pas' {childForm};
var
DllApp : TApplication;
DLLScr: TScreen;{$R *.res}
procedure ExitDLL(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
begin
Application := DLLApp;
Screen := DLLScr;
end;
end;
procedure run_form(parent:THandle);stdcall;
var
childForm: TchildForm;
begin childForm:=TchildForm.Create(Application);
childForm.ParentWindow:=parent;
childForm.Show;
childForm.Align:=alclient;
end;
exports
run_form name 'rums';
begin
DLLApp := Application;
DLLScr := Screen;
DLLProc := @ExitDLL; // DLLProc 在SysInit单元中end.
----------------調用,
unit UTestForm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, RzTabs, StdCtrls, Buttons, Menus, ExtCtrls;type
TShowDLLForm = procedure(aHandle: THandle); stdcall; //定義一個函数指针
EDLLError = class(Exception);
TTestForm = class(TForm)
rzpgc: TRzPageControl;
tbs: TRzTabSheet;
MainMenu1: TMainMenu;
test1: TMenuItem;
procedure test1Click(Sender: TObject); private
DLLHandle: THandle;
{ Private declarations }
public
{ Public declarations }
end;var
TestForm: TTestForm;implementation
procedure rums(parent:THandle);stdcall;external 'UDllFrom.dll';
{$R *.dfm}procedure TTestForm.test1Click(Sender: TObject);
begin
rums(tbs.Handle);
end;end.
-------------------------問題依舊在,也是出刺那个错误
implementation
procedure rums(app:THandle;parent:TWinControl);stdcall;external 'UDllFrom.dll';
{$R *.dfm}procedure TTestForm.test1Click(Sender: TObject);
begin
rums(Application.Handle,tbs);
end;end.
提示的是:rtl140.bpl错误。。好多异常。。
---------
library UDllFrom;{ 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,
forms,
Dialogs,
controls,
windows,
UChildForm in 'UChildForm.pas' {childForm};
var
DllApp : TApplication;
DLLScr: TScreen;{$R *.res}
procedure ExitDLL(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
begin
Application := DLLApp;
Screen := DLLScr;
end;
end;
procedure ShowForm(app:TApplication; parent:TWinControl);stdcall;
var
childForm: TchildForm;
begin
Application := app;
childForm := TchildForm.Create(Application);
childForm.ParentWindow := parent.Handle;
childForm.Show;
childForm.Align := alClient;
end;
exports
ShowForm name 'rums';
begin
DLLApp := Application;
DLLScr := Screen;
DLLProc := @ExitDLL; // DLLProc 在SysInit单元中end.
---------------------这里是照抄的,
测试。