PDA

View Full Version : Issues with transfering string from Delphi DLLs



Michael Hartlef
15-12-2006, 11:46
Hi guys,

I heard that you guys having issues with string transfer from a Delphi DLL. Delphi has it's own way of handling strings. They can be as long as you want them too. To if you want to get a pointer to a string like in C/C++, you have to transmit PChar(yourstring). I hope that helps.

A good read about Delphi strings and how the store the content is this page:

http://delphi.about.com/od/beginners/l/aa071800a.htm

Cu
Michael

ErosOlmi
15-12-2006, 12:40
Thank you Michael. We will have a look.

We have already done something for C interface passing strings.
We have created a common way to allocate string buffers between thinCore.dll and modules developed using C passing a pointer to a buffer where the first bytes are controls flags to understand the method of buffer allocation, the owner of the buffer (Module or Core) and who is responible for deallocation (again Core or Module).

I've already checked Turbo Delphi help file on strings. There are some different types. What I would like to have is something very close to OLE32 strings so able to store NULL bytes too. I suppose PChar is something very close to ANSI strings where a NULL byte indicate the end of the string and there is no clue of what is the real size of the allocated buffer.

In any case, PChar will be the "escape" solution but I would like to check all the other possibilities before using it.

Thanks a lot
Eros

kryton9
15-12-2006, 18:14
I read the article and still don't get it, but I did see the pchar as being the magic format for working with windows api calls it says :)

Thanks Mike and Eros, Delphi is neat. It is nice to know can use both languages together to do almost anything from what I can see so far!!