Hallo,
mein Problem ist folgendes, wenn ich eine Klasse an eine
DLL übergebe und anschließend auf eine class var zugreife stimmt der Wert in der class var nicht. (Ist ja auch logisch, da executable/lib
beide die class var in ihrem Data-Segment speichern)
Beispiel:
Deklaration der Klasse:
Delphi-Quellcode:
type
TFoobar = class
class var Foo: Integer;
procedure Bar(I: Integer);
end;
TFoobarProc = procedure (MainModule: TFoobar);
procedure TFoobar.Bar(I: Integer);
begin
writeln(I);
end;
Library:
Delphi-Quellcode:
procedure Init(MainModule: TFoobar);
begin
MainModule.Bar(MainModule.Foo);
end;
exports
Init;
Executable
Delphi-Quellcode:
var
aFoobar: TFoobar;
begin
aFoobar := TFoobar.Create;
aFoobar.Foo := 42;
aFoobar.Bar(aFoobar.Foo);
TFoobarProc(GetProcAddress(LoadLibrary('lib.dll'), 'Init'))(aFoobar);
readln;
end.
Ausgabe:
Zitat:
42
0
Wünschenswert wäre es, beide zweimal 42 als Ausgabe zu erhalten.
Kennt einer eine Möglichkeit dies umzusetzen?
Gruß,
Win32