The data is read only for the DLL developer, so perhaps this will work 
fine then.  Is the way I've written the C++ struct correct to give to a 
plugin developer?

Thanks,
Ross.

----- Original Message ----- 
From: "Jason Nelson" <[EMAIL PROTECTED]>
To: "Borland's Delphi Discussion List" <[email protected]>
Sent: Friday, February 09, 2007 3:16 AM
Subject: Re: C++ DLL accessing Delphi strings


Ok, well what you're doing there MIGHT almost work provided that the 
strings
are READ ONLY.

But since you want to change the strings, you're going to have issues 
with a
couple of things:

I'm not warranting that my knowledge here is totally right.... but I 
think
some of these points are worth double-checking.

1. Pascal strings maintain a reference count which is made thread-safe 
via
bus locks (disassemble some string processing to see the ASM code).
2. Pointers to pascal strings (i think) point to the beginning of the 
string
data to be compatible with pchars with the auxiliary data to the LEFT of 
the
pointer.  So if you're going to send them delphistring structs, you 
might
need to do a bit of pointer subtraction.  I could be wrong on this 
though.

Jason



There are some other string OLE types that are more suited for this type 
of
thing.

----- Original Message ----- 
From: "Ross Levis" <[EMAIL PROTECTED]>
To: "Delphi Discussion List" <[email protected]>
Sent: Tuesday, February 06, 2007 9:33 PM
Subject: C++ DLL accessing Delphi strings


> I've adding a plugin DLL interface to my Delphi app so 3rd party DLL's 
> can
> utilize functions in my app.  I'm not going to change pascal strings 
> into
> pChars just to suit C++ developers so I need to write the 
> documentation
> describing a record structure containing strings for a C++ developer.
>
> I know very little about the C language.  Can someone confirm if I 
> have
> this right please.
>
> MyRecord = packed record
>  Artist: String;
>  Title: String;
>  Duration: Integer;
>  Year: Word;
>  Gender: ShortInt;
>  BPM: Byte;
>  Cuedb: SmallInt;
>  Cue: LongWord;
> end;
>
> typedef struct {
>  int StringLen;
>  char String;
> } delphistring;
>
> typedef struct{
>  delphistring *Artist;
>  delphistring *Title;
>  int Duration;
>  unsigned short Year;
>  signed char Gender;
>  unsigned char Byte;
>  short Cuedb;
>  unsigned long Cue;
> } MyRecord;
>
> Many thanks,
> Ross. 

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to