Thema: Delphi Dll und Variablen-Scope

Einzelnen Beitrag anzeigen

Sämy

Registriert seit: 4. Nov 2004
Ort: Basel (CH)
76 Beiträge
 
Delphi 2007 Professional
 
#1

Dll und Variablen-Scope

  Alt 29. Nov 2007, 09:49
Hallo

Ich habe eine Klasse, die ich als Singleton(nur eine Instanz) definiere:
Delphi-Quellcode:
type
  TPluginManager = class
  public
    class function getInstance: TPluginManager;
  end;

var
  instance: TPluginManager;

implementation

class function TPluginManager.getInstance: TPluginManager;
begin
  if not Assigned(instance) then
    instance := TPluginManager.Create;
  Result := instance;
end;
Wenn ich nun also TPluginManager.getInstance aufrufe, so bekomme ich dessen Instanz zurück.
Ich arbeite jedoch mit Dll's und wenn ich von dort aus TPluginManager.getInstance aufrufe, erhalte ich nicht mehr die in der Applikation erzeugte Instanz, sondern eine neue wird erstellt.
Wie kann ich dieses Problem umgehen?

Besten Dank!
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
  Mit Zitat antworten Zitat