?
Solved

DataModule inside a DLL?

Posted on 2003-03-28
4
Medium Priority
?
1,829 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 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