Tyring to get the icon of the desktop or "My Documents" or...
-
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
-
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
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