Heres one for the gurus -

Assume  a long string variable is declared locally to a method and is
assigned a string and the string variable is then typecast as an integer and
used in - say - a windows message by assigning it to the message lparam.

The question is when the message is received by another form / thread is it
valid to then typecast the lparam back to a string and use it ?

I have tried many variations of this scenario and it seems to work OK but am
uneasy about whether or not this is safe. I assume it isn't as the local
string variable (which points to the actual string) is on the stack and is
not maintained after the method is exited but what I really am concerned
about is the reference count for the string - has it been increased by
typecasting it to an integer / pointer whatever ...

I have used some of Marco Cantu's code to try and examine the strings
reference count and it always appears to be -1 if the string is a local
variable although it works correctly for field or global.

All very confusing :-)

I would like to know how the code knows when to inc / dec / dispose the
stirng / array reference count.

Cheers

Paul Lowman

_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to