Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

DataModule inside a DLL?

Posted on 2003-03-28
4
Medium Priority
?
1,896 Views
Last Modified: 2012-06-27
I'm developing a modular system (one main .exe and variuos .DLLs) with Delphi 5. I'd like to know the best way to share a database connection with all modules. People have suggested me to put a DataBase component inside each .DLL, but i don't think this is the best way, because each module is gonna make it's own connection to the DataBase Server (InterBase)... I'm trying to put a DataModule inside a .DLL and make it available for each module (.DLL), but i'm having trouble when transferring data between DataModule and the modules...

Does anyone have messed with something like this? Is it really possible to put a DataModule inside a DLL and make it available for all the program? If so, how can I do it, PLEASE????!!!
0
Comment
Question by:bootsector
2 Comments
 
LVL 9

Accepted Solution

by:
mocarts earned 300 total points
ID: 8224650
first, you must put in uses ShareMem for exe and dll's projects as first, for proper memory handling with reference counted resoruces as strings, interfaces..
next, export from your *connection* DLL function which returns Database component
function GetDB: TDatabase; stdcall;
begin
  Result := DataModule1.Database1;
end;

exports
  GetDB;
end.
load this dll as first and save Handle of library somewhere in global variable.
to other dll's which requires Database pass this library handle and these dll's then can find this procedure pointer and respectively get database component:
type
  TGetDB = function: TDatabase; stdcall;

function NeedDatabase: TDatabase;
var
  gdb: TGetDB;
begin
  @gdb := GetProcAddress(hPassedConnectionDLLHandle, 'GetDB');
  if @gdb <> nil then
    Result := GetDB;
end;

that's my idea how..
mo.
0
 

Expert Comment

by:CleanupPing
ID: 9316564
bootsector:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question