With Freepascal you can also use the "old school" way:
Code:
path:=ExtractFilePath(ParamStr(0));
(No need for pChar as you can see.)