#include "shellprv.h" #pragma hdrstop #include "fstreex.h" #include "idlcomm.h" // returns SHAlloc() (COM Task Allocator) memory LPTSTR SHGetCaption(HIDA hida) { UINT idFormat; LPTSTR pszCaption = NULL; LPITEMIDLIST pidl; switch (HIDA_GetCount(hida)) { case 0: return NULL; case 1: idFormat = IDS_ONEFILEPROP; break; default: idFormat = IDS_MANYFILEPROP; break; } pidl = HIDA_ILClone(hida, 0); if (pidl) { TCHAR szName[MAX_PATH]; if (SUCCEEDED(SHGetNameAndFlags(pidl, SHGDN_NORMAL, szName, ARRAYSIZE(szName), NULL))) { TCHAR szTemplate[40]; UINT uLen = LoadString(HINST_THISDLL, idFormat, szTemplate, ARRAYSIZE(szTemplate)) + lstrlen(szName) + 1; pszCaption = SHAlloc(uLen * SIZEOF(TCHAR)); if (pszCaption) { wsprintf(pszCaption, szTemplate, (LPTSTR)szName); } } ILFree(pidl); } return pszCaption; } // This is not folder specific, and could be used for other background // properties handlers, since all it does is bind to the parent of a full pidl // and ask for properties STDAPI SHPropertiesForPidl(HWND hwndOwner, LPCITEMIDLIST pidlFull, LPCTSTR pszParams) { LPITEMIDLIST pidlLast; IShellFolder *psf; HRESULT hres; if (SHRestricted(REST_NOVIEWCONTEXTMENU)) { return HRESULT_FROM_WIN32(E_ACCESSDENIED); } hres = SHBindToIDListParent(pidlFull, &IID_IShellFolder, &psf, &pidlLast); if (SUCCEEDED(hres)) { IContextMenu *pcm; hres = psf->lpVtbl->GetUIObjectOf(psf, hwndOwner, 1, &pidlLast, &IID_IContextMenu, 0, &pcm); if (SUCCEEDED(hres)) { #ifdef UNICODE CHAR szParameters[MAX_PATH]; #endif CMINVOKECOMMANDINFOEX ici = { SIZEOF(CMINVOKECOMMANDINFOEX), 0L, hwndOwner, #ifdef UNICODE "properties", szParameters, #else c_szProperties, pszParams, #endif NULL, SW_SHOWNORMAL }; #ifdef UNICODE if (pszParams) SHUnicodeToAnsi(pszParams, szParameters, ARRAYSIZE(szParameters)); else ici.lpParameters = NULL; ici.fMask |= CMIC_MASK_UNICODE; ici.lpVerbW = c_szProperties; ici.lpParametersW = pszParams; #endif // record if shift or control was being held down SetICIKeyModifiers(&ici.fMask); hres = pcm->lpVtbl->InvokeCommand(pcm, (LPCMINVOKECOMMANDINFO)&ici); pcm->lpVtbl->Release(pcm); } psf->lpVtbl->Release(psf); } return hres; } STDAPI Multi_GetAttributesOf(IShellFolder2 *psf, UINT cidl, LPCITEMIDLIST* apidl, ULONG *prgfInOut, PFNGAOCALLBACK pfnGAOCallback) { HRESULT hres = NOERROR; UINT iidl; ULONG rgfOut = 0; for (iidl=0; iidl