Maybe I am stupid!

Quote
Joshua Cannon Butcher wrote:

> Okay, I have a .DLL file that has a ParseString() function in it, it parses
> a string, and stores that bits in a TStringList.  Here is the problem.

> Lets say I have a list of file masks like:

> *.EXE;*.COM;*.BAT;*.PIF

> I tell it to parse using the ; (semi-colon) as the delimiter.  It creates 4
> strings and stores them in a TStringList as I described.

> Now, the function that calls the parser to parse the string of masks is
> ALSO in the .DLL, it is called GetFileList.  It works FINE when the .DLL
> calls it internally, but when I have a program call GetFileList()
> externally, it causes an invalid page fault.  This code used to work when I
> had it pass an array of strings, but I wanted to make it more programming
> friendly.  Can anyone tell me objects are so hard to operate o in DLLs?  Is
> it because they have their own data segment?  I just want it to work!

> Thank you to anyone who may be able to help me!  If anyone needs further
> clarification of the problem, please ask me to help, I really need this
> resolved.

> Joshua
> CEO CompuSource Pro!

Hi Josh,
        If I remember my Windows memory management correctly you have
got it in one.  In order for windows to pass information between DLL's
and other applications/DLL's I suspect Windows will do either one of the
following a) use registers to pass data or b) if the registers can't
contain the data the DLL will establish a Shared memory pool to pass the
information back and forth.  Soooo in you DLL you are trying to return a
TStringList object which in reality is a pointer to a TStringList object
which is allocated on the heap which is ...... you guessed it in a data
segment accessable only to the DLL.  So you application gets the
returned pointer to the TStringList and tries to access it and lo and
behold a GPF.  The upshot of all of this is that without significantly
changing Delphi's memory model (very yukky) you cannot pass objects to
and from DLL's (I'm sure there are some work arounds but what a
kludge).  You would be better off to do one of the following.

Either go back to the old array method (easy.... :-) )
or
Provide an object like interface ( programmer friendly )

Hope this helps

P.S. and no your not stoopid if ya wanna see stoopid go to a VB news
group (now there are some stoooooopid postings)

Ross Dawson
Developer
County NatWest
Melbourne Australia.