Returns either the parsing path for the specified item, or its in folder name. The in folder name will be returned when the parsing path is a GUID (which typically shouldn't be displayed to the user).
| 819 | // folder name. The in folder name will be returned when the parsing |
| 820 | // path is a GUID (which typically shouldn't be displayed to the user). |
| 821 | std::optional<std::wstring> GetFolderPathForDisplay(PCIDLIST_ABSOLUTE pidl) |
| 822 | { |
| 823 | TCHAR parsingPath[MAX_PATH]; |
| 824 | HRESULT hr = GetDisplayName(pidl, parsingPath, SIZEOF_ARRAY(parsingPath), SHGDN_FORPARSING); |
| 825 | |
| 826 | if (FAILED(hr)) |
| 827 | { |
| 828 | return std::nullopt; |
| 829 | } |
| 830 | |
| 831 | if (IsPathGUID(parsingPath)) |
| 832 | { |
| 833 | hr = GetDisplayName(pidl, parsingPath, SIZEOF_ARRAY(parsingPath), SHGDN_INFOLDER); |
| 834 | |
| 835 | if (FAILED(hr)) |
| 836 | { |
| 837 | return std::nullopt; |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | return parsingPath; |
| 842 | } |
| 843 | |
| 844 | /* Returns TRUE if a path is a GUID; |
| 845 | i.e. of the form: |
no test coverage detected