Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Tyring to get the icon of the desktop or "My Documents" or...

Tyring to get the icon of the desktop or "My Documents" or...

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mynab
    wrote on last edited by
    #1

    Hello, I am trying to get the icon of those special locations but not the index in the system image list but the icon file and the index in the icon file. I use the following code: IShellFolder *pshf = NULL; SHGetDesktopFolder(&pshf); if (pshf != NULL) { void *pv = NULL; CItemIDList idlist(strPath); LPCITEMIDLIST apidl = LPCITEMIDLIST(idlist); HRESULT rc = pshf->GetUIObjectOf(NULL, 1, &apidl, IID_IExtractIcon, NULL, &pv); if (pv) { TCHAR szIconFile[MAX_CHAR]; memset(szIconFile, 0, MAX_CHAR); INT nIconIndex = 10; UINT nFlags; if ( ((IExtractIcon*)pv)->GetIconLocation(GIL_FORSHELL, szIconFile, MAX_CHAR, &nIconIndex, &nFlags) == S_OK && strlen(szIconFile) != 0) { // we got the solution return true; } } } This looks good but it does not work: if strPath is set to a folder then I get the icon 0 of explorer.exe which is not the good one. Most of the time nIconIndex is equal to 0. Can someone help me on this? Thanks mynab

    M 1 Reply Last reply
    0
    • M mynab

      Hello, I am trying to get the icon of those special locations but not the index in the system image list but the icon file and the index in the icon file. I use the following code: IShellFolder *pshf = NULL; SHGetDesktopFolder(&pshf); if (pshf != NULL) { void *pv = NULL; CItemIDList idlist(strPath); LPCITEMIDLIST apidl = LPCITEMIDLIST(idlist); HRESULT rc = pshf->GetUIObjectOf(NULL, 1, &apidl, IID_IExtractIcon, NULL, &pv); if (pv) { TCHAR szIconFile[MAX_CHAR]; memset(szIconFile, 0, MAX_CHAR); INT nIconIndex = 10; UINT nFlags; if ( ((IExtractIcon*)pv)->GetIconLocation(GIL_FORSHELL, szIconFile, MAX_CHAR, &nIconIndex, &nFlags) == S_OK && strlen(szIconFile) != 0) { // we got the solution return true; } } } This looks good but it does not work: if strPath is set to a folder then I get the icon 0 of explorer.exe which is not the good one. Most of the time nIconIndex is equal to 0. Can someone help me on this? Thanks mynab

      M Offline
      M Offline
      mynab
      wrote on last edited by
      #2

      ok i think i kinda fixed the code by using BindToObject on the desktop shell folder and it is working better: i do not get the icon 0 of explorer.exe for all my stuff!! but still it does not seem to work: for instance for "my documents" i always get the standard folder icon instead of the nice one. so my question comes back to: how can i know the icon displayed for a particular folder. i do not want to treat the "my documents" by hardcoding and getting the stuff from the registry using its CLSID because "my pictures", "my videos"... should be handled also! thanks for any reply and happy new year!! mynab

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups