Object references and dll's in Delphi1
I have been trying to do some manipulations on objects passed (as reference)
from an exe to a dll. Sometimes this works, sometimes it doesn't.
After digging in some articles on Compuserve and such, I have understood
that a virtual method can cause problems in Delphi1 when called from a dll,
if the object was created in the exe ( and vice versa ).
To give an example of some funny things that happen.
in the exe :
...
aBitmap := TBitmap.Create;
DllFunction( aBitMap, par1 , par2 );
...
in the dll :
function DllFunction( aBItmap : TBitmap ; par1,par2 : integer ) :
TMemorystream;
begin
...
DoSomeThingWith( aBitmap.Handle );
...
end;
This worked fine when the declaration of the function looked like this :
function DllFunction( aBitmap : TBitmap ) : TMemorystream;
Also with the new declaration everything works fine when you step through
the code with the de{*word*81} (the exe code of course).
But when you run outside of the IDE there is an access violation when you
try to do something with the handle.
When I compiled all the code into the exe everything worked fine also.
My guess is that it has something to do with the stack. It is the only thing
that was different in all those cases.
To cut a long story short : does anybody have any suggestions on what to do
with this ??