Board index » delphi » Accessing Main app data from within a DLL

Accessing Main app data from within a DLL

We have a (small) main Delphi app (fsMDIForm) that loads lots of DLL's at
startup.  These DLL's each contain a number of Delphi fsMDIChild forms
making up a
functional area for our product.  This allows us to add new functionality,
by releasing new DLL's that are located/verified/added_to_the_main_menu at
run time.  The main app holds a tstringlist of the DLL's it has found.

 Our Options.DLL contains a multi-tab form, with one tab per DLL.
This allows the users to configure various settings etc.

 My problem is that I need to know, from inside the Options.DLL,
which other DLL's are loaded.  This information will be used to suppress
(make invisible) the inappropriate tabs.  Now the information is sitting in
a tstringlist of the parent app, I just need to know how to get at it.

 I do not want to pass this stringlist to each and every DLL child
form when I create it, I want to be able to call a function (or proc) in the
parent form and have the tstringlist passed back to me.

 Any ideas anyone?

 Thanks in Advance !!

 Martin

mdoug...@vectaplc.com

 

Re:Accessing Main app data from within a DLL


"Martn Doughty" <mdoug...@vectaplc.com> wrote in
<3a35e94a$1_2@dnews>:

Quote
>We have a (small) main Delphi app (fsMDIForm) that loads lots of
>DLL's at startup.  These DLL's each contain a number of Delphi
>fsMDIChild forms making up a
>functional area for our product.  This allows us to add new
>functionality, by releasing new DLL's that are
>located/verified/added_to_the_main_menu at run time.  The main app
>holds a tstringlist of the DLL's it has found.

> Our Options.DLL contains a multi-tab form, with one tab per DLL.
>This allows the users to configure various settings etc.

> My problem is that I need to know, from inside the Options.DLL,
>which other DLL's are loaded.  This information will be used to
>suppress (make invisible) the inappropriate tabs.  Now the
>information is sitting in a tstringlist of the parent app, I just
>need to know how to get at it.

> I do not want to pass this stringlist to each and every DLL child
>form when I create it, I want to be able to call a function (or
>proc) in the parent form and have the tstringlist passed back to
>me.

Martin,

You should be able to cast the TStringList as an integer and pass it
to a DLL:

  // In main form:
  function GetStringListReference : integer;
  begin
    Result := Integer(FoundDLLsStringList);
  end;

  // In the DLL:
  var
    NewStringList : TStringList;
  begin
    NewStringList := TStringList(GetStringListReference);
  end;

HTH,

Chris.
---------------

Re:Accessing Main app data from within a DLL


If you want to get the data on demand but don't want to pass them to the
DLLs, use a "Memory-Mapped File". This technique allows you to share (and
modify) data among applications and DLLs. It's described -- and well
coded -- in a November 1997 Delphi Informant magazine article at
http://www.delphizine.com/features/1997/11/di199711gd_f/di199711gd_f.asp.
You'll also find a (to my eyes and beleaguered mind) slightly less
comprehensible introduction to the same technique in Marco Cantu's Mastering
Delphi 5. The Informant article describes an application and provides sample
code to share individual string and integer values, but this can easily be
adapted to whatever data structures you want to use.
--
Stephen Aberle {{8^{d}
Programmer, Unipharm Wholesale {*word*110} Ltd.
mailto:stephe...@unipharm.com

Other Threads