Also, ich hab da irgendwie immer noch ein Verständnisproblem: Ich möchte gerne in einer ActiveX-Komponente gemeinsam genutzte Werte halten. Also nach dem Motto: Programm 1 initialisiert die DLL und die entsprechenden Eigenschaften und Programm 2 (das danach gestartet wird), liest die Werte aus. Aber das scheint nicht zu funktionieren - wohl weil ActiveX-DLLs als In-Process-Komponente laufen. Wie kann ich´s dann auf die Reihe kriegen?
Hallo
Ja das geht natürlich so nicht. Was sind denn das genau für Werte? Unter umständen kann ja das Program1 über die Dll eine Datei (XML) erstellen und Program2 über die Dll diese wieder einlesen…
gruss, Giuseppe
[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]
Hallo Giuseppe,
ja, ich hab das inzwischen erstmal so ähnlich gemacht - zwar über die Registry, aber egal.
Es geht mir auch irgendwie mehr ums „Prinzip“. In der MSDN-Library gibt es einen Artikel „Guidelines for Creating Root Objects“ und darin steht u.a.:
Instancing for Root Objects
The functionality your root object provides depends heavily on which value you choose for the Instancing property of its class module: PublicNotCreatable, SingleUse, GlobalSingleUse, MultiUse, or GlobalMultiUse.
PublicNotCreatable Root Objects
If your root object is marked PublicNotCreatable, client applications cannot create instances of it using the New operator or the CreateObject function. While this may seem somewhat upside down — most people will expect the root object to be a way to get at all the other objects in your object model — in conjunction with a global object or a Connector object, as described earlier in this topic, it can be a way to allow clients to share a single instance of your root class.
In order to give clients access to the root object in this case, you must give your public creatable objects (such as the Connector object or the Globals object) a property that returns a reference to the root object, as shown here:
Property Get Root() As Root
Set Root = gRoot
End Property
Note that this does not create circular references, because the dependent objects are not holding actual references to the Root object; they are only using Property Get to return a global reference.
You can also implement a global object with such a property, as described earlier in this topic.
Ich kam durch den Satz „… it can be a way to allow clients to share a single instance of your root class.“ auf die Idee. Scheint aber nicht für DLLs zu gelten …
Gute Nacht und Gruß
Uni
Hallo
Das geht schon, aber eben nur im gleichen Prozess.
Gruss
Hallo Uni,
Bei einer „ActiveX-DLL“ sind auch die Daten nur innerhalb dieses Processes sichtbar. Wenn ein anderes Programm, das gleiche Object benutzt wird eine neu Kopie erstellt, welche dann innerhalb des Speicherbereichs des zweiten Programms abgearbeitet wird. Die beiden Kopien „wissen“ nicht, dass noch eine weitere existiert.
Eine ActiveX-EXE wird als egenständiges Programm ausgeführt und besitzt auch einen eigenen Speicherbereich. Wenn ein Programm eine solche benutzen will, so meldet es sich bei dieser an, dadurch „weiss“ die „ActiveX-EXE“ wieviele, und welche, Programme sich bei ihr angemeldet haben. Normalerweise wird die „ActiveX-EXE“ nur einmal gestartet.
MfG Peter(TOO)
Danke Peter und Giuseppe für die Infos.
Uni