I\'m converting my applications to Delphi 2009 and faced an intriguing issue with some calls that need to convert a string (wide) to AnsiString.
Here\'s an example to de
Gamecat explicit conversion works. I'm explaining the problem in more detail below so that perhaps someone can point to a better solution.
I'm using the following function to retrieve the application compilation date:
function LinkerTimeStamp(const FileName: string): TDateTime;
var
LI: TLoadedImage;
begin
{$IFDEF UNICODE}
Win32Check(MapAndLoad(PAnsiChar(AnsiString(FileName)), nil, @LI, False, True));
{$ELSE}
Win32Check(MapAndLoad(PChar(FileName), nil, @LI, False, True));
{$ENDIF}
Result := LI.FileHeader.FileHeader.TimeDateStamp / SecsPerDay + UnixDateDelta;
UnMapAndLoad(@LI);
end;
MapAndLoad requires a PAnsiChar for the ImageName Parameter so I need to convert the unicode string. Is there any other alternative as to explicitly convert to AnsiString first?