Responding to your third question - it depends what you mean by safe.
PChar(anAnsitString) is always a valid cast in the sense that it will not raise an exception or seg fault, because of the way that the Pascal AnsiString type is defined.
However, AnsiStrings can contain embedded #0 characters (since their length is not determined by the position of #0), so such casts may not give you the results you expect. Here's a little example:
program Project1;
{$mode objfpc}{$H+}
var
anS: AnsiString;
aP: PChar;
begin
anS:= 'first'#0'second';
aP:=PChar(anS);
WriteLn('Displaying AnsiString: "',anS,'"');
WriteLn('Displaying PChar cast: "',aP, '"');
ReadLn;
end.
It might be better to start a new thread for somewhat unrelated questions (this helps people searching for specific topics in future, since they don't have to wade through a long rambling conversation).