MCPcopy Create free account
hub / github.com/bumptop/BumpTop / GetSystemIcon

Method GetSystemIcon

trunk/win/Source/BT_WindowsOS.cpp:3316–3393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3314}
3315
3316HICON WindowsSystem::GetSystemIcon(QString FilePath, int indx)
3317{
3318 /*
3319 path p(FilePath, native);
3320 if (exists(p))
3321 {
3322 IExtractIcon * pei = NULL;
3323 IShellFolder2 * psf = winOS->GetShellFolderFromAbsDirPath(p.branch_path().native_directory_string());
3324 LPCITEMIDLIST * pidlArray = new LPCITEMIDLIST[1];
3325 pidlArray[0] = winOS->GetRelativePidlFromAbsFilePath(FilePath);
3326 if (SUCCEEDED(psf->GetUIObjectOf(NULL, 1, pidlArray, IID_IExtractIcon, NULL, (void **) &pei)))
3327 {
3328 int iconIndex = 0;
3329 TCHAR iconPath[MAX_PATH];
3330 UINT result = 0;
3331
3332 if (SUCCEEDED(pei->GetIconLocation(GIL_FORSHELL, iconPath, MAX_PATH, &iconIndex, &result)))
3333 {
3334 HICON largeIcon;
3335 HICON smallIcon;
3336 if (SUCCEEDED(pei->Extract(iconPath, iconIndex, &largeIcon, &smallIcon, 256)))
3337 {
3338 return largeIcon ? largeIcon : smallIcon;
3339 }
3340 }
3341 }
3342 }
3343 */
3344
3345
3346 SHFILEINFO FileInfo = {0};
3347 HICON largeIcon = NULL;
3348 UINT rtrn = NULL, iconId;
3349
3350 if (indx == -1 || !GLOBAL(settings).enableHiResIcons || (FilePath.size() > 3 && FilePath.contains("lnk")))
3351 {
3352 // Get a list of files specified by Path
3353 SHGetFileInfo((LPCWSTR) FilePath.utf16(), -1, &FileInfo, sizeof(SHFILEINFO), SHGFI_ICON);
3354 return FileInfo.hIcon;
3355 }else{
3356 // Lower Case it
3357 FilePath = FilePath.toLower();
3358
3359 // Poll using this function (EXE only)
3360 if (FilePath.size() > 3 && FilePath.contains("exe"))
3361 {
3362 // Get the high res version of this icon
3363 if (GLOBAL(settings).enableHiResIcons && FilePath.contains("lnk"))
3364 {
3365 fsManager->getShortcutTarget(FilePath, &FilePath);
3366 }
3367
3368 rtrn = PrivateExtractIcons((LPCWSTR) FilePath.utf16(), 0, 256, 256, &largeIcon, &iconId, 1, 0);
3369
3370 if (!largeIcon)
3371 {
3372 // Failsafe if the above line fails, passes it on to the ImageList
3373 SHGetFileInfo((LPCWSTR) FilePath.utf16(), -1, &FileInfo, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX);

Callers

nothing calls this directly

Calls 3

getShortcutTargetMethod · 0.80
sizeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected