Home > Back-end >  DLL encapsulation forms use DEV controls, the main program out of an error
DLL encapsulation forms use DEV controls, the main program out of an error

Time:10-12

Information about error:
1. The DELPHI version: Delphi2010 DEV version control 12.1.5
2. The system overall framework is: form are encapsulated into a DLL for the main program, called
3. Call DLL code below
DLL code:
The library Login;

{Important note about DLL memory management: ShareMem must be the
The first unit in your library 's USES clause AND your project' s (select
The Project - the View Source) USES clause if your DLL exports any procedures or
Functions provides 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 get the using BORLNDMM. DLL, pass the string information
Using PChar or ShortString parameters.}

USES the
SysUtils,
Classes,
Forms,
Windows,
Messages,
ADODB,
Frm_Login in 'Frm_Login. Pas' {FrmLogin},
UPublic in '.. \ Public \ UPublic pas';

{$R *. Res}

Var
DLLApp: TApplication;

The function CallLoginForm (var App: TApplication; Conn: TADOConnection) : Boolean; Export; Stdcall;
The begin
DBcon:=Conn.
{call form for Application, the obvious function is to make your form fusion to the calling program, through which can also has a lot of operation}
Application:=App;//will DLL Application to App
FrmLogin:=TFrmLogin. Create (App);
FrmLogin. ShowModal;
end;

{rewritten Dll entrypoint function, otherwise the program will go wrong}
Procedure DLLUnloadProc (Reason: Integer); The register;
The begin
{DLL to cancel the call, send DLL_PROCESS_DETACH news, at this time will return to for the DLL Application itself}
If a tiny=DLL_PROCESS_DETACH then Application:=DLLApp;
end;

Exports
CallLoginForm;

The begin
{stored in advance the entrance of the DLL DLL Application}
DLLApp:=Application;
{DllProc: DLL entry function pointer, Delphi was defined as DllProc: TDLLProc; }
{at this point to our own definition of function}
DLLProc:=@ DLLUnloadProc;
End.

Call DLL main program code:
Definition:
Var
FrmMain: TfrmMain;
//load call interface
//login
The function CallLoginForm (var App: TApplication; Conn: TADOConnection) : Boolean; Stdcall; External 'Login. DLL';
Call:
CallLoginForm (Application, UPublic. SqlServerDBConn);
4. Problem description: DLL encapsulation forms without using DEV controls, using Delphi take control case, everything is ok, no problem,
Into the DEV controls, the main program calls the DLL form normal, function using normal, also is in the main program exits will error
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
PEIS. Exe - application error
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
X039c90a0 0 x01ca5132 instruction references of "0" memory, the memory not to "read",


To terminate the program, please click "ok",
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sure
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

After two individual information search, have 2 more
1. DLL form release without handle,
This possibility should be smaller, because, after all, without using DEV controls all normal
2. Skin control problems lead to
People think this can be quite large, because the DEV control is the need to use the skin


For the great god help to look at, help the younger brother to solve solution, is really don't know how to deal with,

CodePudding user response:

I also met, the problem of Dev, I think he is a bug

CodePudding user response:

You finally how to deal with?

CodePudding user response:

No one knows how to deal with

CodePudding user response:

Add the Vcl reference

CodePudding user response:

Estimation is the problem of GDI +

CodePudding user response:

Add the VCL reference tried, can't

CodePudding user response:

No great god help you

CodePudding user response:

Increase in the DLL initialization and exit functions! Old and new versions of the slightly different
-- -- -- -- -- -- -- -- -- -- -- -- -- --
WebXone - BS program tool

CodePudding user response:

refer to the eighth floor FengLinYuShu response:
add the initialization and exit functions in the DLL! Old and new versions of the slightly different
-- -- -- -- -- -- -- -- -- -- -- -- -- --
WebXone - BS program tool


Can say how to add function? And function how some? Thank you,

CodePudding user response:

The begin
CoInitialize (nil);
DxInitializeGDIPlus;
DllApplication:=Application;//DllApplication preservation is a DLL APP variable pointer
DLLProc:=@ DLLUnloadProc;
End.
The library HXJXC;

{Important note about DLL memory management: ShareMem must be the
The first unit in your library 's USES clause AND your project' s (select
The Project - the View Source) USES clause if your DLL exports any procedures or
Functions provides 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 get the using BORLNDMM. DLL, pass the string information
Using PChar or ShortString parameters.}



USES the
Sharemem,
SysUtils,
Classes,
Windows,
Forms,
ActiveX,
DxGDIPlusAPI,
Controls,
UModel in '.. {\ hxComm \ uModel pas' Modelfrm};

{$R *. Res}


Procedure DLLUnloadProc (Reason: Integer); The register;
The begin
If a tiny=DLL_PROCESS_DETACH then
The begin
Application:=DllApplication;
PubDMFrm:=nil;
PubShareInfoObj:=nil;
DoSetStatus:=nil;
DxFinalizeGDIPlus;
CoUninitialize;
end;
end;

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related