<p>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.</p>

<p>Here's an example to demonstrate the issue I'm having:</p>

<pre><code>var
  s: PAnsiChar;

...

s := PAnsiChar(Application.ExeName);
</code></pre>

<p>With Delphi 2007 and previous versions, s := PChar(Application.ExeName) would return the application exe path.</p>

<p>with Delphi 2009, s := PAnsiChar(Application.ExeName) returns only 'E'.</p>

<p>My guess is that's because I'm converting a unicode string to an ansi string but how can I convert it so that a PAnsiChar gets the full string?</p>

I have no Delphi 2009 here, so I can't check it. But maybe you have to try:
```
```
s := PAnsiChar(AnsiString(Application.ExeName));
```
```
As gabr already pointed, this is not a very good practice, and you will only use it if you are 100% sure. The string only contains characters that have a direct mapping to the ANSI range.
That's why you should get a warning because you are converting Unicode to ANSI.