LPITEMIDLIST get_folder_pidl (const char *rawpath) { if (NULL==rawpath) return NULL; char path [MAX_PATH]; char temp [MAX_PATH]; unquote(temp, rawpath); if (false == is_relative_path(temp)) { if (is_alpha(temp[0]) && temp[1] == ':' && temp[2] == 0) temp[2] = '\\', temp[3] = 0; return sh_getpidl(NULL, temp); } const char *p = temp; int id = get_csidl(&p); if (NO_CSIDL == id || CSIDL_BLACKBOX == id || CSIDL_CURTHEME == id) { GetBlackboxPath(path, MAX_PATH); if (NO_CSIDL != id) path[strlen(path)-1] = 0; if (p) strcat(path, p); return sh_getpidl(NULL, path); } // special folders, like CONTROLS LPITEMIDLIST pID1, pID; if (NOERROR != SHGetSpecialFolderLocation(NULL, id, &pID1)) return sh_getpidl(NULL, temp); if (NULL == p) { pID = duplicateIDlist(pID1); } else { pID = NULL; // a subdirectory is specified, like APPDATA\microsoft // so get its local pidl and append it IShellFolder* pThisFolder = sh_get_folder_interface(pID1); if (pThisFolder) { LPITEMIDLIST pID2 = sh_getpidl(pThisFolder, p+1); if (pID2) { pID = joinIDlists(pID1, pID2); m_free(pID2); } } } SHMalloc_Free(pID1); return pID; }
void MenuItem::ShowContextMenu(const TCHAR *path, const struct _ITEMIDLIST *pidl) { struct _ITEMIDLIST *new_pidl = NULL; if (NULL == pidl && path) pidl = new_pidl = sh_getpidl(NULL, path); Menu *pSub = GetContextMenu(pidl); if (new_pidl) m_free(new_pidl); if (pSub) { m_pMenu->HideChild(); LinkSubmenu(pSub); ShowSubMenu(); } }