//--------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation 1991-1994 // // File: viewcomm.c // // Common functions used among fstreex.c, netviewx.c, dirvesx.c, ... // //--------------------------------------------------------------------------- #include "shellprv.h" #pragma hdrstop #include "idlcomm.h" LPTSTR SHGetCaption(HIDA hida) { UINT idFormat, uLen; TCHAR szTemplate[40]; TCHAR szName[MAX_PATH]; LPTSTR pszCaption = NULL; LPITEMIDLIST pidl; switch (HIDA_GetCount(hida)) { case 0: // Review: Can this ever happen? Assert(FALSE); goto Error1; case 1: idFormat = IDS_ONEFILEPROP; break; default: idFormat = IDS_MANYFILEPROP; break; } pidl = HIDA_ILClone(hida, 0); if (!pidl) { goto Error1; } if (FAILED(_SHGetNameAndFlags(pidl, SHGDN_NORMAL, szName, ARRAYSIZE(szName), NULL))) { goto Error2; } uLen = LoadString(HINST_THISDLL, idFormat, szTemplate, ARRAYSIZE(szTemplate)) + lstrlen(szName) + 1; pszCaption = SHAlloc(uLen*SIZEOF(TCHAR)); if (pszCaption) { wsprintf(pszCaption, szTemplate, (LPTSTR)szName); } Error2:; ILFree(pidl); Error1:; 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 HRESULT SHPropertiesForPidl(HWND hwndOwner, LPCITEMIDLIST pidlFull, LPCTSTR lpParameters) { HRESULT hres = ResultFromScode(E_OUTOFMEMORY); LPITEMIDLIST pidlCopy = ILClone(pidlFull); if (pidlCopy) { LPITEMIDLIST pidlLast; IShellFolder *psf; hres = SHBindToIDListParent(pidlCopy, &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 c_szPropertiesAnsi, szParameters, #else c_szProperties, lpParameters, #endif NULL, SW_SHOWNORMAL }; #ifdef UNICODE WideCharToMultiByte(CP_ACP, 0, lpParameters, -1, szParameters, ARRAYSIZE(szParameters), NULL, NULL); ici.fMask |= CMIC_MASK_UNICODE; ici.lpVerbW = c_szProperties; ici.lpParametersW = lpParameters; #endif hres = pcm->lpVtbl->InvokeCommand(pcm, (LPCMINVOKECOMMANDINFO)&ici); pcm->lpVtbl->Release(pcm); } psf->lpVtbl->Release(psf); } ILFree(pidlCopy); } return hres; } HRESULT WINAPI Multi_GetAttributesOf(LPSHELLFOLDER psf, UINT cidl, LPCITEMIDLIST* apidl, ULONG *prgfInOut, PFNGAOCALLBACK pfnGAOCallback) { HRESULT hres = NOERROR; UINT iidl; ULONG rgfOut = 0; for (iidl=0; iidluType = STRRET_CSTR; // Return no name if failure pStrRet->cStr[0] = '\0'; #ifdef UNICODE if (SHGetPathFromIDList(pidlFull, szName)) { pStrRet->pOleStr = (LPOLESTR)SHAlloc((lstrlen(szName)+1)*SIZEOF(TCHAR)); if ( pStrRet->pOleStr != NULL ) { lstrcpy(pStrRet->pOleStr, szName); pStrRet->uType = STRRET_OLESTR; hres = S_OK; } else { hres = E_OUTOFMEMORY; } } #else if (SHGetPathFromIDList(pidlFull, pStrRet->cStr)) { hres = NOERROR; } #endif else { hres = E_INVALIDARG; } ILFree(pidlFull); } else { hres = E_OUTOFMEMORY; } return hres; }