| 8 | #include "PathUtils.h" |
| 9 | |
| 10 | HICON GetHIconFromFile(std::wstring_view path) |
| 11 | { |
| 12 | // Get the image list index of the icon |
| 13 | SHFILEINFO sfi; |
| 14 | if (!SHGetFileInfo(path.data(), 0, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX)) return NULL; |
| 15 | |
| 16 | // Get the jumbo image list |
| 17 | IImageList* piml; |
| 18 | if (FAILED(SHGetImageList(SHIL_JUMBO, IID_PPV_ARGS(&piml)))) return NULL; |
| 19 | |
| 20 | // Extract an icon |
| 21 | HICON hico; |
| 22 | piml->GetIcon(sfi.iIcon, ILD_TRANSPARENT, &hico); |
| 23 | |
| 24 | // Clean up |
| 25 | piml->Release(); |
| 26 | |
| 27 | // Return the icon |
| 28 | return hico; |
| 29 | } |
| 30 | |
| 31 | HBITMAP GetHBitmapFromFile(std::wstring_view path) |
| 32 | { |