You could also register the classes in the
procedure Register;
of the package.
--
Pete
====
Audio compression components, DIB graphics controls, FastStrings
http://www.droopyeyes.com
Read or write articles on just about anything
http://www.HowToDoThings.com
"Peter Morris" <pe...@removethis.droopyeyes.com> wrote in message
news:4117...@newsgroups.borland.com...
Thats mean even if the initialization and finalization function exist in the
BPL (View with dependency walker: @UnitName@initialization$qqrv) they may
not be executed by the delphi framework at all. I will have to call my self
or place elseware the functionnailty you describe.
"Rob Kennedy" <.> wrote in message news:4117c571$1...@newsgroups.borland.com...
> Eric Lacroix wrote:
> > I use the RegisterClass and the UnregisterClass procedure to register
> > external metaclass from other BPL or from the executable itself. When i
use
> > the RegisterClass procedure inside a initialization section of another
unit
> > and when this unit is not referenced into any other unit, the
initialization
> > section is not fired. This only append when the unit is linked into the
BPL
> > when i add this unit into the executable everything work find, same case
if
> > a add a reference to this unit.
>
> I came across the same problem a week ago.
>
> If your program is compiled using run-time packages, and your program
> uses at least one of the units in your package, then that package will
> be included in your program's list of required pacakges. (Choose the
> Information item from the Project menu to see that list.)
>
> The packages on that list are loaded automatically by Windows as it
> loads your EXE. Since Windows doesn't know about packages and
> initialization sections, it does not call the InitializePackage
> procedure. That procedure gets called automatically if you use the
> LoadPackage procedure. InitializePackage calls all a package's
> initialization sections.
>
> Any of the package's units that appear on your EXE's uses clauses will
> get initialized because the EXE start-up code will call them as it calls
> all the normal units' initialization sections.
>
> What you've discovered is that any "standalone" units in the package
> will not be initialized. They can't be initialized when the package
> first loads since the OS doesn't know that's necessary. They aren't
> initialized by the EXE since the EXE doesn't use those units. The
> package can't always initialize itself when it's loaded because of the
> vagaries of how Windows loads DLLs.
>
> What you need to do is initialize your package manually. I mentioned
> InitializePackage above. Call that in your DPR file. I have some code
> like this in my program to initialize a package called mcdb.bpl:
>
> var
> MCDB: THandle;
> begin
> MCDB := GetModuleHandle('MCDB.bpl');
> if MCDB <> 0 then InitializePackage(MCDB);
>
> Applciation.Initialize;
> Application.CreateForm(TMultiMain, MultiMain);
> Application.Run;
>
> if MCDB <> 0 then FinalizePackage(MCDB);
> end;
>
> InitializePackage only initializes the units that haven't already been
> initialized by the EXE's automatic start-up code. By checking the handle
> value for 0, I allow myself to turn off run-time packages --
> InitializePackage crashes when given a 0 handle, which is what
> GetModuleHandle returns when the package isn't loaded.
>
> I'm not as comfortable with the call to FinalizePackage, though. I
> haven't confirmed that all my package's unit's finalization sections
> really get executed at the proper times. I haven't looked into it,
> though, since my finalization sections aren't performing any critical
> operations -- just freeing memory that would get freed by the OS moments
> later anyway.
>
> Your other option is to load the package completely dynamically with
> LoadPackage and UnloadPackage. You won't be able to use any of the
> package's units in your program code.
>
> --
> Rob
>
> P.S. to Team B: Eric cross-posted his message to three newsgroups, none
> of which really seems appropriate, and I cross-posted my response. For
> future reference, what should I have done instead? Introduce yet another
> newsgroup and set follow-ups?
First why do you post in the BASM groupe ??
And second please read > http://info.borland.com/newsgroups/guide.html
>> Do not crosspost or multipost your message. Post your message to the
single most appropriate group. <<
Lars G
-A
If you do that, then your program cannot directly use any of the units
within that package. For some designs, that might be appropriate, but
for others, it's not.
--
Rob
For the crossposting, but it seam that several group are non working, like
Borland.Public.Delphi.Ide even Borland.Public.Delphi.Language.ObjectPascal.
And because i dont know where to post my question i made it available into a
few group.
"Lars" <l...@adslhome.dk> wrote in message
news:4117d1bc$1...@newsgroups.borland.com...
> For the crossposting, but it seam that several group are non working, like
> Borland.Public.Delphi.Ide even Borland.Public.Delphi.Language.ObjectPascal.
> And because i dont know where to post my question i made it available into a
> few group.
Some groups have been closed and are now read-only. This doesn't mean
you can cross post. Please choose only one group or your messages will
be cancelled.
--
Marc Rohloff [TeamB]
marc rohloff at myrealbox dot com