解决方案 »
- 用数据库字段做变量问题。帮忙!!!!
- 俺真晕了,advStringGrid是不是用编码也无法实现ctrl多选?非连续的多选。捣鼓了一晚上也没有整出来。
- Application.Set_Value怎么用
- 一个关于数据库的建立的问题
- 在繁體操作系統中安裝簡體的SQL SERVER2000後,其中的存儲過程內創建臨時表的語句無效?
- Timage控件不能完全显示图片,怎么样才能让他出现左右、上下滚动条?怎样才能实现鼠标对图象的拖动?
- delphi程序在英文操作系统vista下界面乱码
- 高分求助!
- 我在QUERY控件里执行 select top 100 * from 表名?为什么会出错?帮帮我,谢谢
- 请问端口怎样禁用?一定给分
- delphi XE5 andriod连接 webservice乱码问题
- delphi7的奇怪故障!
以下是Dll代码
library PDllTest;uses
// FastMM4,
SysUtils,
Forms,
Messages,
Windows,
Classes,
Graphics,
UGlobdata in 'Sample_Delphi_DLL\UGlobdata.pas',
uUnload in 'Sample_Delphi_DLL\uUnload.pas' {FrmUnload},
Prodave60 in 'Sample_Delphi_DLL\Prodave60.pas',
PubFuns in 'Sample_Delphi_DLL\PubFuns.pas',
uAbout in 'Sample_Delphi_DLL\uAbout.pas' {FrmAbout},
uAGinfo in 'Sample_Delphi_DLL\uAGinfo.pas' {FrmAGinfo},
uBitRead in 'Sample_Delphi_DLL\uBitRead.pas' {FrmBitRead},
uBitTest in 'Sample_Delphi_DLL\uBitTest.pas' {FrmBitTest},
Ucontection in 'Sample_Delphi_DLL\Ucontection.pas' {FrmContection},
uDBnumber in 'Sample_Delphi_DLL\uDBnumber.pas' {FrmDBCount},
UDbRead in 'Sample_Delphi_DLL\UDbRead.pas' {FrmDBRead},
uDBWrite in 'Sample_Delphi_DLL\uDBWrite.pas' {FrmDBWrite},
uDiagBuf in 'Sample_Delphi_DLL\uDiagBuf.pas' {FrmDiagBuf},
uFieldRead in 'Sample_Delphi_DLL\uFieldRead.pas' {FrmFieldRead},
uFieldWrite in 'Sample_Delphi_DLL\uFieldWrite.pas' {FrmFieldWrite};{$R *.res}
var
DLLApp: TApplication;
DLLScreen: TScreen;
TheForm: TForm;
TheClass: TPersistentClass;
DllHandle:Thandle;
Procedure GetLoadConInfo(DllHWD:Thandle;var ConInfo:TTLoadCon);stdcall;
begin
ConInfo:=LoadCon;
DllHandle:=DLLHWD;
end;procedure RunTestDLL(DllHWD:Thandle;ADLLName, FormName, FormCaption: string;
APP: TApplication; AScreen: TScreen) stdcall;
begin
Application := App;
Screen := AScreen;
RegisterClasses([TFrmUnload, TFrmAbout,TFrmAGinfo,TFrmBitRead,TFrmBitTest,
TFrmContection,TFrmDBCount,TFrmDBRead,TFrmDBWrite,
TFrmDiagBuf,TFrmFieldRead,TFrmFieldWrite]);
TheClass := GetClass('T' + FormName);
if (TheClass <> nil) and TheClass.InheritsFrom(TForm) then begin
TheForm := TForm(TheClass.Create).Create(nil);
AppHWD :=TheForm;
DllHandle:=DLLHWD;
TheForm.Caption:=FormCaption;
try
TheForm.ShowModal;
finally
FreeAndNil(TheForm)
end;
end;
end;procedure DLLUnloadProc(dwReason: Dword);
begin
if dwReason = DLL_PROCESS_DETACH then begin //当进程退出时
Application := DLLApp; //恢复
Screen := DLLScreen;
if FrmUnload<>nil then FreeAndNil(FrmUnload); // 卸载时释放资源
if FrmAbout<>nil then FreeAndNil(FrmAbout);
if FrmAGinfo<>nil then FreeAndNil(FrmAGinfo);
if FrmBitRead<>nil then FreeAndNil(FrmBitRead);
if FrmBitTest<>nil then FreeAndNil(FrmBitTest);
if FrmContection<>nil then FreeAndNil(FrmContection);
if FrmDBCount<>nil then FreeAndNil(FrmDBCount);
if FrmDBRead<>nil then FreeAndNil(FrmDBRead);
if FrmDBWrite<>nil then FreeAndNil(FrmDBWrite);
if FrmDiagBuf<>nil then FreeAndNil(FrmDiagBuf);
if FrmFieldRead<>nil then FreeAndNil(FrmFieldRead);
if FrmFieldWrite<>nil then FreeAndNil(FrmFieldWrite);
SendMessage(Application.Handle, WM_CLOSE, 0, 0);// 关闭dll
if DllHandle<>0 then
FreeLibrary(DllHandle);//释放dll 资源
end;
end;exports
RunTestDLL,
GetLoadConInfo;
begin
DLLApp := Application; //保存 DLL 中初始的 Application 对象
DLLScreen := Screen;
DLLProc := @DLLUnloadProc; //保证 DLL 卸载时恢复原来的 Application
end.