It depends on what you are trying to do with it. Do you use the address yourself or pass it into external code?
If you use it yourself, try thoiz_vd answer. As a general rule, keep as much of your internal string processing as possible in a string . This will save you a lot of trouble.
On the other hand, if you pass it to an external routine, for example, something in the Windows API, you must make sure that the data is in the format that the API expects. This is slightly less clear than in the first case, because when Delphi switched from AnsiString to UnicodeString as the main string type, they canceled many winapi headers in the Windows module to allow the equivalent widescreen version of the routines that had the strings.
So, check what you are sending it to. If PChar is required for this, use thoiz_vd's answer. But if it expects PAnsiChar , redeclare pAddr as PAnsiChar .
source share