GetFileTitle的本地化版本? [英] localized version of GetFileTitle?

查看:102
本文介绍了GetFileTitle的本地化版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拼命地尝试猜测在给定文件路径的情况下如何检索照片的本地化文件名.例如,给定路径

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资源管理器和内置的图像查看器程序都显示Méduses"一词,代表法文Win7.这是否适用于其他版本的Windows?

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仅删除扩展名和文件夹路径,给了我水母",这不是我想要的,并且在阅读了MSDN和google之后,似乎Windows Media Format的 http://msdn.microsoft.com/en-us/library/dd798508(v = VS.85 ).aspx 界面在这里无济于事.我丢失了谷歌搜索技能,或者记录得很差.请帮忙吗?

GetFileTitle only removes the extension and folder path giving 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 ?

谢谢

推荐答案

我不确定这种情况(我从未遇到过这种形式的本地化文件名),但是我知道这是获得官方唯一支持的方式系统目录和标准Windows applet等的本地化文件名将使用IShellFolder :: GetDisplayNameOf.

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.

因此,简要地讲,您需要获取文件(SHParseDisplayName)的PIDL,绑定到其父文件夹(SHBindToParent),然后使用SHGDN_INFOLDER标志查询显示名称.

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.

附录:一种更简单的方法(我完全忘记了)是使用SHGetFileInfo来获取带有SHGFI_DISPLAYNAME标志的显示名称.这意味着您不需要混搭PIDL. SHGetFileInfo本质上是包装各种外壳COM类(例如IShellFolder)的包装-两种方式的关键都是使用外壳来获取显示名称,而不是基础API函数.

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.

这篇关于GetFileTitle的本地化版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆