开发者

localized version of GetFileTitle?

开发者 https://www.devze.com 2023-01-26 15:46 出处:网络
I am desperately attempting to guess how the localized filename for photos can be retrieved given the path to that file. For instance, given the path

I am desperately attempting to guess how the localized filename for photos can be retrieved given the path to that file. For instance, given the path

c:\images\jellyfish.png - Win 7 explorer and the built in image viewer program both display the word "Méduses" for a french win 7. Does this hold true for other versions of windows ?

GetFileTitle only removes the extension and folder path givi开发者_如何学Pythonng me 'jellyfish' which is not what I am after, and after having read through MSDN and google it seems that the Windows Media Format's http://msdn.microsoft.com/en-us/library/dd798508(v=VS.85).aspx interface wouldn't help here. Either I have lost my googling skills or this is very poorly documented. Help please ?

thank you


I'm not sure about this case specifically (I've never encountered localized filenames in that form) but the only officially supported way I know of to get the localized filenames for system directories and the standard Windows applets, etc., is to use IShellFolder::GetDisplayNameOf.

So briefly, you need to get a PIDL for the file (SHParseDisplayName), bind to its parent folder (SHBindToParent), and then query for the display name using the SHGDN_INFOLDER flag.

Addendum: An even easier way (which I completely forgot about) is to use SHGetFileInfo to get the display name with the SHGFI_DISPLAYNAME flag. This means you don't need to muck around with PIDLs. SHGetFileInfo is essentially a wrapper around the various shell COM classes like IShellFolder - either way, the key is to use the shell to get the display name rather than the underlying API functions.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号