3

Good morning ... I am listing all files in a directory ... But I am facing the following problem ... When folders are coming All in English ... But the operating system is Ministry of Defence for the Portuguese ... How to list it according to the operating system language:

Ex: Program Files (EN) -> Arquivos de Programa (PT)

if FindFirst (directory + '*. *', faAnyFile, search_rec) = 0 then
       begin
         repeat
           Form4.ListView1.Items.Add.Caption: = search_rec.Name;
             lista.Add (search_rec.Name);
         Until FindNext (search_rec) <> 0;

         FindClose (search_rec);
       end;
abcd
  • 441
  • 6
  • 24
  • It is the filesystem/OS that is reporting the names like that in the first place. You can verify that by calling the Win32 API `FindFirstFile()` and `FindNextFile()` functions directly. – Remy Lebeau Dec 12 '14 at 16:25
  • 4
    http://msdn.microsoft.com/en-us/library/bb759792%28v=vs.85%29.aspx May not be exactly helpful to call SHGetFileInfo for every folder though. – Sertac Akyuz Dec 12 '14 at 16:27
  • 1
    Thanks for correcting me everyone. I always thought that at install time the OS made directories with localized names. I had not realized that it is always `C:\Program Files` in the file system and then some magic at display time. – David Heffernan Dec 12 '14 at 17:20
  • @SertacAkyuz since there is limited number of Windows standard folders that have localized names it would probably be enough to create lookup list of those folders containing both english and localized names and then comparing every found folder to that list – Dalija Prasnikar Dec 12 '14 at 17:22
  • @DavidHeffernan As far as I know localized names of system folders like Program Files were only used prior Windows 2000. Windows 2000 is also first Windows that supports multilingual user interface (MUI). The data in MUI determines which names is shown for certain system folder. Windows 2000 is also first Windows version which introduced so caled specail folders that can be accesed by using special name like %TEMP% for instnace. By default most common system folders were created as special folders and it is even posible to add new custom special folders for your software. – SilverWarior Dec 12 '14 at 20:34
  • Viewing the PC company data ... was installed an ISO in English and then translated into Portuguese ... – abcd Dec 12 '14 at 21:18

1 Answers1

1

Ok Portuguese:

SHGetFileInfo(PChar(strPath + SearchRec.Name), 0, FileInfo,
                  SizeOf(FileInfo), SHGFI_DISPLAYNAME);
                Listitem.Caption := FileInfo.szDisplayName;
abcd
  • 441
  • 6
  • 24