M$ Vista - mape

Vsi vaši problemi s programsko opremo.
Odgovori
Uporabniški avatar
krho
Prispevkov: 709
Pridružen: 11.01.2003 23:02:56

M$ Vista - mape

Odgovor Napisal/-a krho » 17.02.2008 14:35:11

No preden še kdo od vas naredi doktorat.
The localized versions of Windows Vista use localized folders for things like "C:\Users" and "C:\Program Files". These localized folders ("C:\Benutzer" and "C:\Programme") do not really exists. On disk the English folder exist but Windows Explorer shows only the localized names in its default configuration. So far no problem. But when it comes to other applications the mess starts to begin.

A German user who knows his "C:\Benutzer\MyName\Bilder" folder from the Windows Explorer will start to ask himself what idiots wrote the application he currently uses and that shows C:\Users\MyName\Pictures in the directory edit. He never saw this directory and he can't find it in Windows Explorer or the open/save dialog. As a result he replaces the text in the directory edit by his localized path and presses the OK button. But then suddenly the application tells him that this directory does not exist. But he can navigate to it within the Windows Explorer. So what happend.

The user's application does not convert the localized path in the directory edit to a physical path that can be used in CreateFile/GetFileAttributes/FindFirstFile/... calls. Because none of these function do the conversion it is the responsibility of the programmer to convert all paths that come from user input. This includes edit controls, config files, command line parameters, ...

As a developer you would think that's no problem. Just call a WinAPI function or call a System.IO method that does the conversion. But not this time. Microsoft hasn't implemented such an API. There is the SHGetLocalizedName function but it doesn't convert a whole path. It is restricted to the default paths and every sub directory like the "Pictures" folder can't be localized with it. And even if somebody manages to implement a physical to localized path algorithm with this API, it doesn't help us because we need a bidirectional mapping.
Uredite zbirko filmov, tv serij in iger - http://xcollect.sf.net
Zamenjate leglo virusov s preprostim in naprednim odjemalcem elektronske pošte. - http://www.simail.si

Miha-R
Prispevkov: 2155
Pridružen: 14.05.2001 21:29:53

M$ Vista - mape

Odgovor Napisal/-a Miha-R » 17.02.2008 18:27:12

Lahko bi tekst v celoti preposlal:
This means that it is up to the programmer to write his own mapping functions. But where to begin. Maybe first look for a new API again. Search the Internet and hope that somebody already implemented such a function. But most developers use an English Windows Vista version and aren't aware of this problem. After some google search you have to accept that nobody has written such a function, hasn't released it to the public or you haven't searched hard enough. A look into the JCL wasn't successful either. And the JVCL contains the unit for which I need these mapping functions (TJvDirectoryEdit, TJvFilenameEdit).
What to do? Remember the ShellAPI programming you've done years ago in Delphi 3 and the IShellFolder interface. Have a look at some outdated shell components you wrote years ago and try to build some code that does the mapping.

I do not say that the code is perfect but at least it works and can also map partial localized paths in both directions. The two functions PathGetPhysicalPath and PathGetLocalizedPath are in the JCL/trunk/jcl/source/common/JclFileUtils.pas file.
Vir: http://andy.jgknet.de/blog/archives/90- ... names.html

Miha-R
Prispevkov: 2155
Pridružen: 14.05.2001 21:29:53

M$ Vista - mape

Odgovor Napisal/-a Miha-R » 17.02.2008 18:29:54

In ja, totalna blesarija. Je mogoče kdo izbrskal kakšen blog MSjevcev, zakaj so to uvedli?
Vedno sem želel napisati prav tak odgovor.

Odgovori