MCPcopy Create free account
hub / github.com/HO-COOH/FastCopy / GetHIconFromFile

Function GetHIconFromFile

FastCopy/ImageUtils.cpp:10–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include "PathUtils.h"
9
10HICON 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
31HBITMAP GetHBitmapFromFile(std::wstring_view path)
32{

Callers 1

BitmapMethod · 0.85

Calls 3

dataMethod · 0.80
GetIconMethod · 0.80
ReleaseMethod · 0.45

Tested by

no test coverage detected