ADO in DLL
From: Theuns (theuns_at_softsim.co.za)
Date: 12/01/03
- Next message: Andy Mackie: "Re: Disconnected datasets"
- Previous message: George Christoforakis: "Re: Locktype and performance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Dec 2003 01:42:39 -0800
I have one export procedure that takes on pchar string
argument(parameter) in the DLL.
This function creates a class that on its turn creates a datamodule
that connects to a Access database , it get some data from the DB and
generates a jpg object and save it on the harddrive.
When the procedure is finished the DLL get lots of DLL_THREAD_ATTACH
calls and create new threads untill it I get a Acces
Violation.(Creates about 3 threads)
Previously I did get "Coinitialze not called" when the datamodule is
created , I added ActiveX unit and called Coinitialze(nil), end of
that problem.
How do I fix this problem.
This is my Library code
library MYDLL;
uses
ActiveX ,
SysUtils,
Classes,
Windows,
Jpeg,
Dialogs,
unMyUnit in '..\lib\unMYUnit.pas';
var
aMyObjectClass : TMyObjectClass ;
SaveDllProc: Pointer;
{$R *.res}
Procedure CreateJpeg(aPointerStr : PChar) ;
var
aJpeg : TJPEGImage ;
aStr : String ;
Begin
aStr := aPointerStr ;
Try
ShowMessage(aStr);
aJpeg := TJPEGImage.Create ;
if not Assigned(aMyObjectClass) then
Begin
aMyObjectClass := TMyObjectClass.create('',46,True,True,True);
end ;
aMyObjectClass.Str := aStr ;
if aMyObjectClass.SymbolOK then
Begin
aJpeg.Assign(aMyObjectClass.BMP);
aJpeg.SaveToFile('C:\Projects\JPEGs\1234.jpg');
end ;
finally
FreeAndNil(aJpeg);
end ;
end ; //When Exit here get lots of Process Attach Calls
procedure Init_Destroy(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
begin
aMyObjectClass.Free ;
aMyObjectClass := nil ;
ShowMessage('MyObjectClass Freed');
DllProc := SaveDllProc ;
end;
if Reason = DLL_PROCESS_ATTACH then
begin
end;
end;
Exports
CreateJpeg ;
begin
CoInitialize(nil) ;
SaveDllProc := @Dllproc ;
DllProc := @Init_Destroy ;
Init_Destroy(DLL_PROCESS_ATTACH);
end.
- Next message: Andy Mackie: "Re: Disconnected datasets"
- Previous message: George Christoforakis: "Re: Locktype and performance"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|