Delphi 2007 to Delphi 2010 (String, AnsiString and more)
Posted on 2010-09-02
Me again =X
i like to do the things correctly and not just to silence the compiler =)
Using Delphi 2010, in a project made in Delphi 2007 a lot of bugs corrected...
Anyway, the typecast between String->PAnsiChar and back i have some doubts
function GetSomePath: String;
Result := 'C:\MyFolder\';
WinExec(PAnsiChar(GetSomePath + 'SomeFile.exe'), SW_SHOWNORMAL);
Works but i got...
W1044 Suspicious typecast of string to PAnsiChar over PAnsiChar(GetSomePath)
To silence the compiler i can do
WinExec(PAnsiChar(AnsiString(GetSomePath) + 'SomeFile.exe'), SW_SHOWNORMAL);
But, i really don't know if its the right way... its not i think :S
Can somebody tell me the right way to TypeCast String, AnsiString, PChar, PAnsiChar with no data loss?