Board index » delphi » Re: Problem with plugin in DLL
Kevin
Delphi Developer |
Kevin
Delphi Developer |
Re: Problem with plugin in DLL2005-11-21 04:57:30 AM delphi49 QuoteNo, I thought to use variables with common classes you needed to use |
Kevin
Delphi Developer |
2005-11-21 05:11:38 AM
Re: Problem with plugin in DLLQuote>I think it depends a bit on the variables/classes involved. |
Willi Krenn
Delphi Developer |
2005-11-21 06:14:17 AM
Re: Problem with plugin in DLL
Liz writes:
Quote
'tweaked' to contain the 'correct' values. *g* Sharemem is another topic, yes. Willi |
Brad White
Delphi Developer |
2005-11-22 12:05:27 AM
Re: Problem with plugin in DLL
"Eugene V. Goldberg" <XXXX@XXXXX.COM>writes
Quoteif you dont want to use runtime libs, you can try to patch Graphics.pas The whole assign mechanism depends on each piece being able to recognize which objects it can handle. Your patch will call TFont(Source).PixelsPerInch on any object passed in, even if it is not a TFont. This takes the offset of PixelsPerInch in TFont and reaches into Source and grabs the data at that offset. Even worse is Size. It finds the offset of GetSize and executes whatever code is at that offset in Source. This is fine if Source *happens* to be a TFont. But since your code is telling you that the two versions don't match up, you are playing with fire. It is perfectly legal to call assign on any object knowing that it will only assign what it can. You have broken that guarantee. This is just a time bomb waiting to go off in ways that you won't recognize as related. -- Brad. |
Joe Bain
Delphi Developer |
2005-11-22 03:23:48 AM
Re: Problem with plugin in DLL
Brad White writes:
Quote"Eugene V. Goldberg" <XXXX@XXXXX.COM>writes it is the correct TFont before assigning. -------------- Joe Bain www.iegsoftware.com |
Joe Bain
Delphi Developer |
2005-11-22 03:29:20 AM
Re: Problem with plugin in DLL
Joe Bain writes:
QuoteSearch for my name (Joe Bain) and IsClassInstance in Joe Bain www.iegsoftware.com |
Jirka Meluzín
Delphi Developer |
2005-11-25 05:17:27 AM
Re: Problem with plugin in DLL
Sorry, maybe I dont understand everything you have said, but I have
problem. I remade my dll into packages, but I cant load more than one package. When Im trying load others it causes a exception saying that I cant load plugin.pas because the first package has already loaded plugin.pas before. I dont know what Im doing wrong :( BTW in plugin.pas is the base class of my all plugins, so I must use it in my packages... Thanks for helping to lama :) On Sun, 20 Nov 2005 16:36:29 +0100, Willi Krenn <XXXX@XXXXX.COM> writes: QuoteJirka, |
Willi Krenn
Delphi Developer |
2005-11-25 06:09:32 AM
Re: Problem with plugin in DLL
Jirka,
QuoteSorry, maybe I dont understand everything you have said, but I have that might have e.g. global variables - was linked more than once into your application, you'd have more than one copy of your unit resulting in more than one of the -possibly included- global variables. You'd have a hard time figuring out which of all these global variables were the 'correct' ones.. The Delphi compiler knows about this problem and does not allow multiple inclusion of a unit. (With some exceptions IIRC.) To solve your problem you have to change your plugin-architecture a little bit by introducing another package. (See below) QuoteBTW in plugin.pas is the base class of my all plugins, so I must use it plugins later on are derived from, perhaps some code that scans a directory looking for loadable plugins (packages) etc.. Take this stuff and put it in a package - I will call it 'PluginBasics' for now. Your application module layout should now look something like: <Main.Exe> | | <??><PluginBasics.Bpl> | | <VclXY.Bpl><WhateverYouNeed.Bpl> The "Main.Exe" module can use the routines contained in 'PluginBasics' for triggering loading of plugins at runtime and will probably also use the typedefinitions in one of the units (e.g. plugin.pas) from 'PluginBasics'. Next, you create a real plugin package that uses the types contained in pluginbasics.bpl as a basis and derives new funtionality from it; Let's call this package 'Plugin1' for now: <Plugin1.Bpl> | <PluginBasics.Bpl> | <VclXY.Bpl> Sticking everything together (we finally load the plugin), we get: <Main.Exe><Plugin1.Bpl> | | <PluginBasics.Bpl> | <VclXY.Bpl> With little planing you can figure out a unit-distribution so each unit is linked only once into the whole project (.exe plus all .bpls you load). HTH Willi |