[Lazarus] Windows API calls and german Umlauts
Michael Van Canneyt
michael at freepascal.org
Wed Mar 9 14:00:56 CET 2016
On Wed, 9 Mar 2016, John Landmesser wrote:
> Hi,
>
> if i call a windows API function for special folder, like:
>
>
> uses
> ...
> shlobj;
>
> var
> AppDataPath: Array[0..MaxPathLen] of Char;
> begin
>
> SHGetSpecialFolderPath(0,AppDataPath,CSIDL_STARTUP,false);
> end;
>
> I get on a german localized Windows XP a path containing "\Startmenü\", but the "ü" is "?" in the resulting string.
>
> Howto convert the chars in AppDataPath to get the "Umlauts" correct?
Use the W variant of the call, and user widechar.
var
AppDataPath: Array[0..MaxPathLen] of WideChar;
begin
SHGetSpecialFolderPathW(0,AppDataPath,CSIDL_STARTUP,false);
Then convert to UTF8 using UTF8Encode() if you want to display it in a LCL
application.
Michael.
More information about the Lazarus
mailing list