A
adibyu
Unregistered / Unconfirmed
GUEST, unregistred user!
library ReadMachineRec;
{ 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,
ADODB,
Windows,
ActiveX,
ReadMain in 'ReadMain.pas' {frmReadMain};
var
DLLApplication:TApplication;
DllScreen:TScreen;
Procedure ShowReadMachineRec(aApp:TApplication;DllScr:TScreen;InterfaceFilechar;
ClearAllAfterRead:Boolean;DBCnn:TADOConnection);stdcall;
var
frmReadMain:TfrmReadMain;
begin
CoInitialize(Nil);
[red]//Application:=aApp;
//Screen:=DllScr;[/red] [blue]//为什么这两行不能加,否则退出DLL时就出错。 [/blue]
frmReadMain:=TfrmReadMain.Create(Application);
DllDBCnn:=TADOConnection.Create(Application);
DllDBCnn:=DBCnn;
frmReadMain.Aq_SaveRec.Connection :=DllDBCnn;
frmReadMain.Hide;
frmReadMain.ShowModal;
end;
procedure DLLUnloadProc(Reason: Integer);
begin
if Reason=DLL_PROCESS_DETACH then
begin
CoUnInitialize;
Application:=DLLApplication;
Screen := DLLScreen;
end;
end;
{$R *.res}
exports
ShowReadMachineRec;
begin
DLLApplication:=Application;
DLLScreen := Screen;
DLLProc := @DLLUnloadProc;
DLLUnloadProc(DLL_PROCESS_ATTACH);
end.
调用该DLL并关闭窗体frmReadMain后,出错:
Project F:/MyPro/Test.exe raised too many consecutive exceptions:......
请问这是为什么,如何解决?
{ 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,
ADODB,
Windows,
ActiveX,
ReadMain in 'ReadMain.pas' {frmReadMain};
var
DLLApplication:TApplication;
DllScreen:TScreen;
Procedure ShowReadMachineRec(aApp:TApplication;DllScr:TScreen;InterfaceFilechar;
ClearAllAfterRead:Boolean;DBCnn:TADOConnection);stdcall;
var
frmReadMain:TfrmReadMain;
begin
CoInitialize(Nil);
[red]//Application:=aApp;
//Screen:=DllScr;[/red] [blue]//为什么这两行不能加,否则退出DLL时就出错。 [/blue]
frmReadMain:=TfrmReadMain.Create(Application);
DllDBCnn:=TADOConnection.Create(Application);
DllDBCnn:=DBCnn;
frmReadMain.Aq_SaveRec.Connection :=DllDBCnn;
frmReadMain.Hide;
frmReadMain.ShowModal;
end;
procedure DLLUnloadProc(Reason: Integer);
begin
if Reason=DLL_PROCESS_DETACH then
begin
CoUnInitialize;
Application:=DLLApplication;
Screen := DLLScreen;
end;
end;
{$R *.res}
exports
ShowReadMachineRec;
begin
DLLApplication:=Application;
DLLScreen := Screen;
DLLProc := @DLLUnloadProc;
DLLUnloadProc(DLL_PROCESS_ATTACH);
end.
调用该DLL并关闭窗体frmReadMain后,出错:
Project F:/MyPro/Test.exe raised too many consecutive exceptions:......
请问这是为什么,如何解决?