library TestDll;
uses
ShareMem,
SysUtils,
Classes,
Forms,
windows,
Unit1d in 'Unit1d.pas' {Form1};
var
DLLApp: TApplication;
{$R *.res}
function ShowDllForm1(AHandle:TApplication):integer; stdcall;
var
Form1: TForm1;
begin
Application:=AHandle;
Form1:=TForm1.Create(AHandle);
Form1.Show;
Result:=Form1.SpinEdit1.Value;
end;
procedure DLLUnloadProc(Reason : DWord);
begin
if Reason = DLL_PROCESS_DETACH then Application := DLLApp;//恢复
end;Exports
ShowDllForm index 1,
ShowDllForm1 index 2;
begin
DLLApp := Application; DLLProc := @DLLUnloadProc; //这句怎么起不了作用一样的? ???(*****)
end.调用: TestDll.Dll文件
type
Ta1Form = procedure(AForm:TApplication); stdcall;procedure TFormmain.Button4Click(Sender: TObject);
var AForm: Ta1Form;
lHandle: THandle;
begin
lHandle := LoadLibrary('TestDll.dll');
try
if lhandle = 0 then
raise Exception.Create('不能引导动态链接库...');
@AForm := GetProcAddress(lHandle, 'ShowDllForm1');
if @AForm <> nil then
AForm(Application)
else
RaiseLastWin32Error;
finally
// FreeLibrary(lHandle); //这句一用上,就会主Form不见了。而用了,被调用的子Form又会出现主程序没有完全退出。(在系统里有进程)???(*****)
end;
end;谢谢
uses
ShareMem,
SysUtils,
Classes,
Forms,
windows,
Unit1d in 'Unit1d.pas' {Form1};
var
DLLApp: TApplication;
{$R *.res}
function ShowDllForm1(AHandle:TApplication):integer; stdcall;
var
Form1: TForm1;
begin
Application:=AHandle;
Form1:=TForm1.Create(AHandle);
Form1.Show;
Result:=Form1.SpinEdit1.Value;
end;
procedure DLLUnloadProc(Reason : DWord);
begin
if Reason = DLL_PROCESS_DETACH then Application := DLLApp;//恢复
end;Exports
ShowDllForm index 1,
ShowDllForm1 index 2;
begin
DLLApp := Application; DLLProc := @DLLUnloadProc; //这句怎么起不了作用一样的? ???(*****)
end.调用: TestDll.Dll文件
type
Ta1Form = procedure(AForm:TApplication); stdcall;procedure TFormmain.Button4Click(Sender: TObject);
var AForm: Ta1Form;
lHandle: THandle;
begin
lHandle := LoadLibrary('TestDll.dll');
try
if lhandle = 0 then
raise Exception.Create('不能引导动态链接库...');
@AForm := GetProcAddress(lHandle, 'ShowDllForm1');
if @AForm <> nil then
AForm(Application)
else
RaiseLastWin32Error;
finally
// FreeLibrary(lHandle); //这句一用上,就会主Form不见了。而用了,被调用的子Form又会出现主程序没有完全退出。(在系统里有进程)???(*****)
end;
end;谢谢
解决方案 »
- 绝对必要的日期函数
- 谁能给个源代码及其软件说明文档(如学生信息管理系统,商店会员管理系统,之类都行)
- 这里有没有西安的朋友?高新三路的 西安巨维科技有限公司 咋样?
- 关于 窗体弹出的风格的小问题?
- 用activexform生成的控件,怎么屏蔽掉自动生成的属性啊?
- 关于combobox组件的使用
- DELPHI6的ADOQuery控件,如果在filter(过滤)中同时使用了and和or就会报错.为什么?
- 怎样使用tree view
- 请教:TQUERY控件的active为什么不能设成true,datasource怎么没有下拉的东西呢?
- ROSE2000或98哪有的下载?
- 关于Stream
- 请高手门指教:有关报表的问题?(急急急)
uses
ShareMem,
SysUtils,
Classes,
Forms,
windows,
Unit1d in 'Unit1d.pas' {Form1};
var
DLLApp: TApplication;
{$R *.res}
function ShowDllForm1(AHandle:TApplication):integer; stdcall;
var
Form1: TForm1;
begin
Application:=AHandle;
Form1:=TForm1.Create(AHandle);
Form1.Show;
Result:=Form1.SpinEdit1.Value;
end;
procedure DLLUnloadProc(Reason : DWord);
begin
if Reason = DLL_PROCESS_DETACH then Application := DLLApp;//恢复
end;Exports
ShowDllForm index 1,
ShowDllForm1 index 2;
begin
DLLApp := Application; DLLProc := @DLLUnloadProc; //这句怎么起不了作用一样的? ???(*****)
end.调用: TestDll.Dll文件
type
Ta1Form = procedure(AForm:TApplication); stdcall;procedure TFormmain.Button4Click(Sender: TObject);
var AForm: Ta1Form;
lHandle: THandle;
begin
lHandle := LoadLibrary('TestDll.dll');
try
if lhandle = 0 then
raise Exception.Create('不能引导动态链接库...');
@AForm := GetProcAddress(lHandle, 'ShowDllForm1');
if @AForm <> nil then
AForm(Application)
else
RaiseLastWin32Error;
finally
// FreeLibrary(lHandle); //这句一用上,就会主Form不见了。而用了,被调用的子Form又会出现主程序没有完全退出。(在系统里有进程)???(*****)
end;
end;
我的程序都是静态调用的。//以下是MDI 的主窗口,(就是DELPHI MDI 模板建出来的)
//
unit Main;interfaceuses Windows, SysUtils, Classes, Graphics, Forms, Controls, Menus,
StdCtrls, Dialogs, Buttons, Messages, ExtCtrls, ComCtrls, StdActns,
ActnList, ToolWin, ImgList;type
TMainForm = class(TForm)
MainMenu1: TMainMenu;
File1: TMenuItem;
FileNewItem: TMenuItem;
FileOpenItem: TMenuItem;
FileCloseItem: TMenuItem;
Window1: TMenuItem;
Help1: TMenuItem;
N1: TMenuItem;
FileExitItem: TMenuItem;
WindowCascadeItem: TMenuItem;
WindowTileItem: TMenuItem;
WindowArrangeItem: TMenuItem;
HelpAboutItem: TMenuItem;
OpenDialog: TOpenDialog;
FileSaveItem: TMenuItem;
FileSaveAsItem: TMenuItem;
Edit1: TMenuItem;
CutItem: TMenuItem;
CopyItem: TMenuItem;
PasteItem: TMenuItem;
WindowMinimizeItem: TMenuItem;
StatusBar: TStatusBar;
ActionList1: TActionList;
EditCut1: TEditCut;
EditCopy1: TEditCopy;
EditPaste1: TEditPaste;
FileNew1: TAction;
FileSave1: TAction;
FileExit1: TAction;
FileOpen1: TAction;
FileSaveAs1: TAction;
WindowCascade1: TWindowCascade;
WindowTileHorizontal1: TWindowTileHorizontal;
WindowArrangeAll1: TWindowArrange;
WindowMinimizeAll1: TWindowMinimizeAll;
HelpAbout1: TAction;
FileClose1: TWindowClose;
WindowTileVertical1: TWindowTileVertical;
WindowTileItem2: TMenuItem;
ToolBar2: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton9: TToolButton;
ToolButton7: TToolButton;
ToolButton8: TToolButton;
ToolButton10: TToolButton;
ToolButton11: TToolButton;
ImageList1: TImageList;
procedure FileNew1Execute(Sender: TObject);
procedure FileOpen1Execute(Sender: TObject);
procedure HelpAbout1Execute(Sender: TObject);
procedure FileExit1Execute(Sender: TObject);
private
{ Private declarations }
procedure CreateMDIChild(const Name: string);
public
{ Public declarations }
end;var
MainForm: TMainForm;//这儿加
procedure CreateChildForm(MainApp:TApplication);stdcall; external 'ChildDll.dll';implementation{$R *.DFM}uses About;procedure TMainForm.CreateMDIChild(const Name: string);
begin
{ create a new MDI child window }
//这儿加
CreateChildForm(Application);
end;procedure TMainForm.FileNew1Execute(Sender: TObject);
begin
CreateMDIChild('NONAME' + IntToStr(MDIChildCount + 1));
end;procedure TMainForm.FileOpen1Execute(Sender: TObject);
begin
if OpenDialog.Execute then
CreateMDIChild(OpenDialog.FileName);
end;procedure TMainForm.HelpAbout1Execute(Sender: TObject);
begin
AboutBox.ShowModal;
end;procedure TMainForm.FileExit1Execute(Sender: TObject);
begin
Close;
end;end.以下为CHILDDLL.DLL 的CHILDDLL.DPR文件的内容:
library ChildDll;{ 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
Windows,
SysUtils,
Classes,
Forms,
Child in 'Child.pas' {Form1};var
DllApp : TApplication;
{$R *.RES}procedure MyDLLProc(Reason: Integer);
begin
// DLL is unloading. Restore the Application pointer.
if Reason = DLL_PROCESS_DETACH then
begin
if Assigned(DllApp) then
Application := DllApp;
end;
end;procedure CreateChildForm(MainApp:TApplication);stdcall;export;
var
Child : TForm1;
begin
if not Assigned(DllApp) then
begin
DllApp := Application;
Application := MainApp;
end; Child := nil;
try
Child := TForm1.Create(Application);
Child.Show();
except
Child.Free();
end;
end;exports
CreateChildForm;begin
DLLProc := @MyDLLProc;
end.
//如果你的建不出来请给Mail,
//我将给Nizvoo的例子给你。
在testdll.dll文件中:
procedure DLLUnloadProc(Reason : DWord);
begin
if Reason = DLL_PROCESS_DETACH then Application := DLLApp;//恢复
end;Exports
ShowDllForm index 1,
ShowDllForm1 index 2;
begin
DLLApp := Application; DLLProc := @DLLUnloadProc; //这句怎么起不了作用一样的? ???(*****)
end.
[email protected]
GQn0hrOcMZj1uibAzd54vbaveb6fuq9x798s7EjApOiJMp/cjwGkomv5tZFdUFVhOiotHpjI6byz
tyYhPelMxov+CaywRewdEthcqjiBuP6Eqox+4FiT1k/OGEYhw6oyhlMILNRe2+akg7vxXiVb3Usc
DMDIJh3km6FNJv3rt1ApB2OsHTv7rXi/UPG2KJPjUe5aTcX2p51wG+32fZ35JmP2QLwjFHjrbhPO
T5fJu3zTpF09iduZyhVRAYXfDSMVVM580p47OUZtbvKteFbsCvO4WqHoWvbvS+Iixya7bB1sxzeF
0DZtIt3vaOPBCVUppThBMslURg37KEJnJndgU0o/YrDZ4LcEe9CJuNF8aCMbDk1kD8f7Vckw2r/n
9x/PIMdoxfNFux3/ZLuri9mvzwldudqUmyUWdZbkxOIsoUEVUzX0JZp1nEuvcqERvVJIKlXLZqbg
jiUhB7hA77J4o+iZWdAP6fEobnsZiJzXOpg9BvVki4bl0FjVsF/DER+zZwfub5wmGoh7mga5LKGq
54y+fDv37nFUDmOFoptba20XJG59v79uX2yzi30N93a14+H8BQNysjxkLeCivair6l0O3mlRr9XL
+9ytppVRUTtybozaMSEh6rWPk/ctE+Kz1dXO4V7bj1odV0EeOowlXxc7IiDGnoNfINVRSOXrCxBv
后来又重新发过一次,是一个.zip文件,这次没有分块发送,整个.zip文件发。
sorry.
"Build with runtimes packages" ,没有这个选项?Delphi5和Delphi6都没有?2、静态链接不太好,因为我做的是ERP系统,工程太大,用"静态链接"实在不是很好。
有没有看过[天心ERP系统](fas2000),是用Delphi做的,MDI,动态调用DLL.thank
请问:这个选项选上有什么作用?(对一般工程而言),thank