示例#1
0
/**************************************************************************
 *  CDesktopFolder::GetAttributesOf
 */
HRESULT WINAPI CDesktopFolder::GetAttributesOf(
    UINT cidl,
    PCUITEMID_CHILD_ARRAY apidl,
    DWORD *rgfInOut)
{
    HRESULT hr = S_OK;

    TRACE("(%p)->(cidl=%d apidl=%p mask=%p (0x%08x))\n",
          this, cidl, apidl, rgfInOut, rgfInOut ? *rgfInOut : 0);

    if (cidl && !apidl)
        return E_INVALIDARG;

    if (*rgfInOut == 0)
        *rgfInOut = ~0;

    if(cidl == 0)
        *rgfInOut &= dwDesktopAttributes;
    else
    {
        /* TODO: always add SFGAO_CANLINK */
        for (UINT i = 0; i < cidl; ++i)
        {
            pdump(*apidl);
            if (_ILIsDesktop(*apidl))
                *rgfInOut &= dwDesktopAttributes;
            else if (_ILIsMyComputer(apidl[i]))
                *rgfInOut &= dwMyComputerAttributes;
            else if (_ILIsNetHood(apidl[i]))
                *rgfInOut &= dwMyNetPlacesAttributes;
            else if (_ILIsSpecialFolder(apidl[i]))
                SHELL32_GetGuidItemAttributes(this, apidl[i], rgfInOut);
            else if (_ILIsFolder(apidl[i]) || _ILIsValue(apidl[i]))
            {
                CComPtr<IShellFolder2> psf;
                HRESULT hr = _GetSFFromPidl(apidl[i], &psf);
                if (FAILED_UNEXPECTEDLY(hr))
                    continue;

                psf->GetAttributesOf(1, &apidl[i], rgfInOut);
            }
            else
                ERR("Got an unknown pidl type!!!\n");
        }
    }
    /* make sure SFGAO_VALIDATE is cleared, some apps depend on that */
    *rgfInOut &= ~SFGAO_VALIDATE;

    TRACE("-- result=0x%08x\n", *rgfInOut);

    return hr;
}
示例#2
0
HRESULT SH_ParseGuidDisplayName(IShellFolder2 * pFolder,
                                HWND hwndOwner,
                                LPBC pbc,
                                LPOLESTR lpszDisplayName,
                                DWORD *pchEaten,
                                PIDLIST_RELATIVE *ppidl,
                                DWORD *pdwAttributes)
{
    LPITEMIDLIST pidl;

    if (!lpszDisplayName || !ppidl)
        return E_INVALIDARG;

    *ppidl = 0;

    if (pchEaten)
        *pchEaten = 0;

    UINT cch = wcslen(lpszDisplayName);
    if (cch < 39 || lpszDisplayName[0] != L':' || lpszDisplayName[1] != L':')
        return E_FAIL;

    pidl = _ILCreateGuidFromStrW(lpszDisplayName + 2);
    if (pidl == NULL)
        return E_FAIL;

    if (cch < 41)
    {
        *ppidl = pidl;
        if (pdwAttributes && *pdwAttributes)
        {
            SHELL32_GetGuidItemAttributes(pFolder, *ppidl, pdwAttributes);
        }
    }
    else
    {
        HRESULT hr = SHELL32_ParseNextElement(pFolder, hwndOwner, pbc, &pidl, lpszDisplayName + 41, pchEaten, pdwAttributes);
        if (SUCCEEDED(hr))
        {
            *ppidl = pidl;
        }
        return hr;
    }

    return S_OK;
}