Glad to hear you had some success with the sample code.

Not sure if it helps, but if you can't keep a reference to anything global
in the Delphi dll, then maybe you could just pass a pointer back and forth -
i.e. pass the data from .NET to Delphi initially and have the Delphi code
allocate the memory and pass back a pointer to it, then have the .NET code
pass that pointer to any function that needs it.  I think this is
effectively what I did originally, although I was freeing the buffer
immediately after I'd got what I wanted on the .NET side.

Good luck.

On Thu, Dec 16, 2010 at 5:18 PM, Peter Maddin <petermad...@aapt.net.au>wrote:

>  Hi Matt
>
> Found this concerning state management with a Delphi dll
>
> http://stackoverflow.com/questions/1042686/delphi-dynamic-dll-global-variable
>
> The best options look like
> 1. Use a second dll that is loaded dynamically (and unload it when done).
> 2. Use COM
>
>
> There is also LoadLibraryEx and FreeLibrary (
> http://msdn.microsoft.com/en-us/library/ms684179(v=VS.85).aspx<http://msdn.microsoft.com/en-us/library/ms684179%28v=VS.85%29.aspx>
> )
>
> On 15/12/2010 9:42 PM, Matt Siebert wrote:
>
> I'm not sure about the globals.  I did have success with allocating the
> buffer in Delphi, then cleaning it up in a separate call but can't remember
> if the Delphi code kept a reference to the buffer, or if the .NET code
> passed it into the cleanup call.
>
>

Reply via email to