localized version of GetFileTitle?

前端 未结 1 991
野的像风
野的像风 2021-01-23 18:39

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\\jellyfi

相关标签:
1条回答
  • 2021-01-23 19:34

    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 讨论(0)
提交回复
热议问题