Hi! I'm using Delphi 2009 and get some strange errors using the following code segment:
var
Str : AnsiString;
CharPtr : PAnsiChar;
...
CharPtr := PAnsiChar (Str);
ExecuteInBackgroundThread (
procedure
begin
DoSomething (CharPtr);
end);
I'm guessing that the string is destructed when falling out of scope and under some timing conditions DoSomething will yield the strangest results. So the first question is: am I right?
Second question is: How can I circumvent the string being destructed? What's the proper way to do this?
Thanks in advance.