ReactOS 0.4.15-dev-7705-g2320c37
CViewStatePropertyBag Class Reference
Inheritance diagram for CViewStatePropertyBag:
Collaboration diagram for CViewStatePropertyBag:

Public Member Functions

 CViewStatePropertyBag ()
 
 ~CViewStatePropertyBag () override
 
HRESULT Init (_In_opt_ LPCITEMIDLIST pidl, _In_opt_ LPCWSTR pszPath, _In_ DWORD dwVspbFlags)
 
BOOL IsSameBag (LPCITEMIDLIST pidl, LPCWSTR pszPath, DWORD dwVspbFlags) const
 
STDMETHODIMP Read (_In_z_ LPCWSTR pszPropName, _Inout_ VARIANT *pvari, _Inout_opt_ IErrorLog *pErrorLog) override
 
STDMETHODIMP Write (_In_z_ LPCWSTR pszPropName, _In_ VARIANT *pvari) override
 
- Public Member Functions inherited from CBasePropertyBag
 CBasePropertyBag (DWORD dwMode)
 
virtual ~CBasePropertyBag ()
 
STDMETHODIMP QueryInterface (REFIID riid, void **ppvObject) override
 
 STDMETHODIMP_ (ULONG) AddRef() override
 
 STDMETHODIMP_ (ULONG) Release() override
 
- Public Member Functions inherited from IPropertyBag
HRESULT Read ([in] LPCOLESTR pszPropName, [in, out] VARIANT *pVar, [in] IErrorLog *pErrorLog)
 
HRESULT RemoteRead ([in] LPCOLESTR pszPropName, [out] VARIANT *pVar, [in] IErrorLog *pErrorLog, [in] DWORD varType, [in] IUnknown *pUnkObj)
 
HRESULT Write ([in] LPCOLESTR pszPropName, [in] VARIANT *pVar)
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Protected Member Functions

BOOL _IsSamePidl (LPCITEMIDLIST pidlOther) const
 
BOOL _IsSystemFolder () const
 
BOOL _CanAccessPidlBag () const
 
BOOL _CanAccessUserDefaultsBag () const
 
BOOL _CanAccessFolderDefaultsBag () const
 
BOOL _CanAccessGlobalDefaultsBag () const
 
BOOL _CanAccessInheritBag () const
 
BOOL _CanAccessUpgradeBag () const
 
HKEY _GetHKey (DWORD dwVspbFlags)
 
UINT _GetMRUSize (HKEY hKey)
 
HRESULT _GetMRUSlots (LPCITEMIDLIST pidl, DWORD dwMode, HKEY hKey, UINT *puSlots, UINT cSlots, UINT *pcSlots)
 
HRESULT _GetMRUSlot (LPCITEMIDLIST pidl, DWORD dwMode, HKEY hKey, UINT *pSlot)
 
HRESULT _GetRegKey (LPCITEMIDLIST pidl, LPCWSTR pszBagName, DWORD dwFlags, DWORD dwMode, HKEY hKey, LPWSTR pszDest, INT cchDest)
 
HRESULT _CreateBag (LPITEMIDLIST pidl, LPCWSTR pszPath, DWORD dwVspbFlags, DWORD dwMode, REFIID riid, IPropertyBag **pppb)
 
HRESULT _FindNearestInheritBag (REFIID riid, IPropertyBag **pppb)
 
void _ResetTryAgainFlag ()
 
BOOL _EnsureReadBag (DWORD dwMode, REFIID riid)
 
BOOL _EnsurePidlBag (DWORD dwMode, REFIID riid)
 
BOOL _EnsureInheritBag (DWORD dwMode, REFIID riid)
 
BOOL _EnsureUpgradeBag (DWORD dwMode, REFIID riid)
 
BOOL _EnsureUserDefaultsBag (DWORD dwMode, REFIID riid)
 
BOOL _EnsureFolderDefaultsBag (DWORD dwMode, REFIID riid)
 
BOOL _EnsureGlobalDefaultsBag (DWORD dwMode, REFIID riid)
 
BOOL _EnsureWriteBag (DWORD dwMode, REFIID riid)
 
HRESULT _ReadPidlBag (LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
 
HRESULT _ReadInheritBag (LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
 
HRESULT _ReadUpgradeBag (LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
 
HRESULT _ReadUserDefaultsBag (LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
 
HRESULT _ReadFolderDefaultsBag (LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
 
HRESULT _ReadGlobalDefaultsBag (LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
 
void _PruneMRUTree ()
 

Protected Attributes

LPITEMIDLIST m_pidl = NULL
 
LPWSTR m_pszPath = NULL
 
DWORD m_dwVspbFlags = 0
 
CComPtr< IPropertyBagm_pPidlBag
 
CComPtr< IPropertyBagm_pUpgradeBag
 
CComPtr< IPropertyBagm_pInheritBag
 
CComPtr< IPropertyBagm_pUserDefaultsBag
 
CComPtr< IPropertyBagm_pFolderDefaultsBag
 
CComPtr< IPropertyBagm_pGlobalDefaultsBag
 
CComPtr< IPropertyBagm_pReadBag
 
CComPtr< IPropertyBagm_pWriteBag
 
BOOL m_bPidlBag = FALSE
 
BOOL m_bUpgradeBag = FALSE
 
BOOL m_bInheritBag = FALSE
 
BOOL m_bUserDefaultsBag = FALSE
 
BOOL m_bFolderDefaultsBag = FALSE
 
BOOL m_bGlobalDefaultsBag = FALSE
 
BOOL m_bReadBag = FALSE
 
BOOL m_bWriteBag = FALSE
 
- Protected Attributes inherited from CBasePropertyBag
LONG m_cRefs
 
DWORD m_dwMode
 

Additional Inherited Members

- Public Types inherited from IPropertyBag
typedef IPropertyBagLPPROPERTYBAG
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 

Detailed Description

Definition at line 1204 of file propbag.cpp.

Constructor & Destructor Documentation

◆ CViewStatePropertyBag()

CViewStatePropertyBag::CViewStatePropertyBag ( )
inline

Definition at line 1288 of file propbag.cpp.

#define STGM_READ
Definition: objbase.h:917

◆ ~CViewStatePropertyBag()

CViewStatePropertyBag::~CViewStatePropertyBag ( )
inlineoverride

Definition at line 1290 of file propbag.cpp.

1291 {
1294 }
LPITEMIDLIST m_pidl
Definition: propbag.cpp:1207
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:929

Member Function Documentation

◆ _CanAccessFolderDefaultsBag()

BOOL CViewStatePropertyBag::_CanAccessFolderDefaultsBag ( ) const
protected

Definition at line 1382 of file propbag.cpp.

1383{
1385 return TRUE;
1386
1387 return ((m_dwVspbFlags & SHGVSPB_ALLUSERS) && (m_dwVspbFlags & SHGVSPB_PERFOLDER));
1388}
BOOL _CanAccessUserDefaultsBag() const
Definition: propbag.cpp:1374
#define TRUE
Definition: types.h:120

Referenced by _CanAccessGlobalDefaultsBag(), and _EnsureFolderDefaultsBag().

◆ _CanAccessGlobalDefaultsBag()

BOOL CViewStatePropertyBag::_CanAccessGlobalDefaultsBag ( ) const
protected

Definition at line 1390 of file propbag.cpp.

1391{
1393 return TRUE;
1394
1395 return ((m_dwVspbFlags & SHGVSPB_GLOBALDEAFAULTS) == SHGVSPB_GLOBALDEAFAULTS);
1396}
BOOL _CanAccessFolderDefaultsBag() const
Definition: propbag.cpp:1382

Referenced by _EnsureGlobalDefaultsBag().

◆ _CanAccessInheritBag()

BOOL CViewStatePropertyBag::_CanAccessInheritBag ( ) const
protected

Definition at line 1398 of file propbag.cpp.

1399{
1400 return (_CanAccessPidlBag() || (m_dwVspbFlags & SHGVSPB_INHERIT));
1401}
BOOL _CanAccessPidlBag() const
Definition: propbag.cpp:1369

Referenced by _EnsureInheritBag().

◆ _CanAccessPidlBag()

BOOL CViewStatePropertyBag::_CanAccessPidlBag ( ) const
protected

Definition at line 1369 of file propbag.cpp.

1370{
1371 return ((m_dwVspbFlags & SHGVSPB_FOLDER) == SHGVSPB_FOLDER);
1372}

Referenced by _CanAccessInheritBag(), _CanAccessUserDefaultsBag(), and _EnsurePidlBag().

◆ _CanAccessUpgradeBag()

BOOL CViewStatePropertyBag::_CanAccessUpgradeBag ( ) const
protected

Definition at line 1403 of file propbag.cpp.

1404{
1405 return StrCmpW(m_pszPath, L"Desktop") == 0;
1406}
int WINAPI StrCmpW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:434
#define L(x)
Definition: ntvdm.h:50

Referenced by _EnsureUpgradeBag().

◆ _CanAccessUserDefaultsBag()

BOOL CViewStatePropertyBag::_CanAccessUserDefaultsBag ( ) const
protected

Definition at line 1374 of file propbag.cpp.

1375{
1376 if (_CanAccessPidlBag())
1377 return TRUE;
1378
1379 return ((m_dwVspbFlags & SHGVSPB_USERDEFAULTS) == SHGVSPB_USERDEFAULTS);
1380}

Referenced by _CanAccessFolderDefaultsBag(), and _EnsureUserDefaultsBag().

◆ _CreateBag()

HRESULT CViewStatePropertyBag::_CreateBag ( LPITEMIDLIST  pidl,
LPCWSTR  pszPath,
DWORD  dwVspbFlags,
DWORD  dwMode,
REFIID  riid,
IPropertyBag **  pppb 
)
protected

Definition at line 1534 of file propbag.cpp.

1541{
1542 HRESULT hr;
1543 HKEY hKey;
1546 WCHAR szBuff[64];
1547
1548 if (MODE_CAN_WRITE(dwMode))
1549 dwMode |= STGM_CREATE;
1550
1551 if ((dwVspbFlags & SHGVSPB_ALLUSERS) && (dwVspbFlags & SHGVSPB_PERFOLDER))
1552 {
1553 hr = BindCtx_CreateWithMode(dwMode, &pBC);
1554 if (SUCCEEDED(hr))
1555 {
1556 hr = SHGetDesktopFolder(&psf);
1557 if (SUCCEEDED(hr))
1558 {
1559 hr = psf->BindToObject(m_pidl, pBC, riid, (void **)pppb);
1560 if (SUCCEEDED(hr) && !*pppb)
1561 hr = E_FAIL;
1562 }
1563 }
1564 }
1565 else
1566 {
1567 hKey = _GetHKey(dwVspbFlags);
1568 if (!hKey)
1569 return E_FAIL;
1570
1571 hr = _GetRegKey(pidl, pszPath, dwVspbFlags, dwMode, hKey, szBuff, _countof(szBuff));
1572 if (SUCCEEDED(hr))
1573 hr = SHCreatePropertyBagOnRegKey(hKey, szBuff, dwMode, riid, (void**)pppb);
1574
1576 }
1577
1578 return hr;
1579}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
#define RegCloseKey(hKey)
Definition: registry.h:49
HRESULT _GetRegKey(LPCITEMIDLIST pidl, LPCWSTR pszBagName, DWORD dwFlags, DWORD dwMode, HKEY hKey, LPWSTR pszDest, INT cchDest)
Definition: propbag.cpp:1482
HKEY _GetHKey(DWORD dwVspbFlags)
Definition: propbag.cpp:1424
#define E_FAIL
Definition: ddrawi.h:102
FxAutoRegKey hKey
REFIID riid
Definition: atlbase.h:39
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define STGM_CREATE
Definition: objbase.h:926
EXTERN_C HRESULT WINAPI SHCreatePropertyBagOnRegKey(_In_ HKEY hKey, _In_z_ LPCWSTR pszSubKey, _In_ DWORD dwMode, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: propbag.cpp:575
#define MODE_CAN_WRITE(dwMode)
Definition: propbag.cpp:24
static HRESULT BindCtx_CreateWithMode(DWORD dwMode, IBindCtx **ppbc)
Definition: propbag.cpp:1513
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:68
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by _EnsureFolderDefaultsBag(), _EnsureGlobalDefaultsBag(), _EnsurePidlBag(), _EnsureReadBag(), _EnsureUserDefaultsBag(), and _EnsureWriteBag().

◆ _EnsureFolderDefaultsBag()

BOOL CViewStatePropertyBag::_EnsureFolderDefaultsBag ( DWORD  dwMode,
REFIID  riid 
)
protected

Definition at line 1662 of file propbag.cpp.

1663{
1665 {
1667 if (_IsSystemFolder())
1668 {
1669 _CreateBag(m_pidl, m_pszPath, SHGVSPB_PERFOLDER | SHGVSPB_ALLUSERS,
1670 dwMode, riid, &m_pFolderDefaultsBag);
1671 }
1672 }
1673 return (m_pFolderDefaultsBag != NULL);
1674}
CComPtr< IPropertyBag > m_pFolderDefaultsBag
Definition: propbag.cpp:1214
BOOL _IsSystemFolder() const
Definition: propbag.cpp:1352
HRESULT _CreateBag(LPITEMIDLIST pidl, LPCWSTR pszPath, DWORD dwVspbFlags, DWORD dwMode, REFIID riid, IPropertyBag **pppb)
Definition: propbag.cpp:1534
#define NULL
Definition: types.h:112

Referenced by _ReadFolderDefaultsBag().

◆ _EnsureGlobalDefaultsBag()

BOOL CViewStatePropertyBag::_EnsureGlobalDefaultsBag ( DWORD  dwMode,
REFIID  riid 
)
protected

Definition at line 1676 of file propbag.cpp.

1677{
1679 {
1681 _CreateBag(NULL, m_pszPath, SHGVSPB_GLOBALDEAFAULTS, dwMode, riid, &m_pGlobalDefaultsBag);
1682 }
1683 return (m_pGlobalDefaultsBag != NULL);
1684}
BOOL _CanAccessGlobalDefaultsBag() const
Definition: propbag.cpp:1390
CComPtr< IPropertyBag > m_pGlobalDefaultsBag
Definition: propbag.cpp:1215

Referenced by _ReadGlobalDefaultsBag().

◆ _EnsureInheritBag()

BOOL CViewStatePropertyBag::_EnsureInheritBag ( DWORD  dwMode,
REFIID  riid 
)
protected

Definition at line 1632 of file propbag.cpp.

1633{
1635 {
1638 }
1639 return (m_pInheritBag != NULL);
1640}
BOOL _CanAccessInheritBag() const
Definition: propbag.cpp:1398
HRESULT _FindNearestInheritBag(REFIID riid, IPropertyBag **pppb)
Definition: propbag.cpp:1582
CComPtr< IPropertyBag > m_pInheritBag
Definition: propbag.cpp:1212

Referenced by _ReadInheritBag().

◆ _EnsurePidlBag()

BOOL CViewStatePropertyBag::_EnsurePidlBag ( DWORD  dwMode,
REFIID  riid 
)
protected

Definition at line 1622 of file propbag.cpp.

1623{
1625 {
1626 m_bPidlBag = TRUE;
1627 _CreateBag(m_pidl, m_pszPath, SHGVSPB_FOLDER, dwMode, riid, &m_pPidlBag);
1628 }
1629 return (m_pPidlBag != NULL);
1630}
CComPtr< IPropertyBag > m_pPidlBag
Definition: propbag.cpp:1210

Referenced by _ReadPidlBag().

◆ _EnsureReadBag()

BOOL CViewStatePropertyBag::_EnsureReadBag ( DWORD  dwMode,
REFIID  riid 
)
protected

Definition at line 1612 of file propbag.cpp.

1613{
1614 if (!m_pReadBag && !m_bReadBag)
1615 {
1616 m_bReadBag = TRUE;
1618 }
1619 return (m_pReadBag != NULL);
1620}
CComPtr< IPropertyBag > m_pReadBag
Definition: propbag.cpp:1216

Referenced by Read().

◆ _EnsureUpgradeBag()

BOOL CViewStatePropertyBag::_EnsureUpgradeBag ( DWORD  dwMode,
REFIID  riid 
)
protected

Definition at line 1642 of file propbag.cpp.

1643{
1645 {
1648 }
1649 return (m_pUpgradeBag != NULL);
1650}
BOOL _CanAccessUpgradeBag() const
Definition: propbag.cpp:1403
CComPtr< IPropertyBag > m_pUpgradeBag
Definition: propbag.cpp:1211
HRESULT SHGetDesktopUpgradePropertyBag(REFIID riid, void **ppvObj)
Definition: propbag.cpp:1197

Referenced by _ReadUpgradeBag().

◆ _EnsureUserDefaultsBag()

BOOL CViewStatePropertyBag::_EnsureUserDefaultsBag ( DWORD  dwMode,
REFIID  riid 
)
protected

Definition at line 1652 of file propbag.cpp.

1653{
1655 {
1657 _CreateBag(NULL, m_pszPath, SHGVSPB_USERDEFAULTS, dwMode, riid, &m_pUserDefaultsBag);
1658 }
1659 return (m_pUserDefaultsBag != NULL);
1660}
CComPtr< IPropertyBag > m_pUserDefaultsBag
Definition: propbag.cpp:1213

Referenced by _ReadUserDefaultsBag().

◆ _EnsureWriteBag()

BOOL CViewStatePropertyBag::_EnsureWriteBag ( DWORD  dwMode,
REFIID  riid 
)
protected

Definition at line 1814 of file propbag.cpp.

1815{
1816 if (!m_pWriteBag && !m_bWriteBag)
1817 {
1818 m_bWriteBag = TRUE;
1820 if (m_pWriteBag)
1821 {
1823 if (m_dwVspbFlags & SHGVSPB_INHERIT)
1824 _PruneMRUTree();
1825 }
1826 }
1827 return (m_pWriteBag != NULL);
1828}
CComPtr< IPropertyBag > m_pWriteBag
Definition: propbag.cpp:1217

Referenced by Write().

◆ _FindNearestInheritBag()

HRESULT CViewStatePropertyBag::_FindNearestInheritBag ( REFIID  riid,
IPropertyBag **  pppb 
)
protected

Definition at line 1582 of file propbag.cpp.

1583{
1584 *pppb = NULL;
1585
1586 HKEY hKey = _GetHKey(SHGVSPB_INHERIT);
1587 if (!hKey)
1588 return E_FAIL;
1589
1590 UINT cSlots, anSlots[64];
1591 if (FAILED(_GetMRUSlots(m_pidl, 0, hKey, anSlots, _countof(anSlots), &cSlots)) || !cSlots)
1592 {
1594 return E_FAIL;
1595 }
1596
1597 HRESULT hr = E_FAIL;
1598 WCHAR szBuff[64];
1599 for (UINT iSlot = 0; iSlot < cSlots; ++iSlot)
1600 {
1601 StringCchPrintfW(szBuff, _countof(szBuff), L"Bags\\%d\\%s\\Inherit", anSlots[iSlot],
1602 m_pszPath);
1603 hr = SHCreatePropertyBagOnRegKey(hKey, szBuff, STGM_READ, riid, (void**)pppb);
1604 if (SUCCEEDED(hr))
1605 break;
1606 }
1607
1609 return hr;
1610}
HRESULT _GetMRUSlots(LPCITEMIDLIST pidl, DWORD dwMode, HKEY hKey, UINT *puSlots, UINT cSlots, UINT *pcSlots)
Definition: propbag.cpp:1446
#define FAILED(hr)
Definition: intsafe.h:51
unsigned int UINT
Definition: ndis.h:50
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530

Referenced by _EnsureInheritBag().

◆ _GetHKey()

HKEY CViewStatePropertyBag::_GetHKey ( DWORD  dwVspbFlags)
protected

Definition at line 1424 of file propbag.cpp.

1425{
1426 if (!(dwVspbFlags & (SHGVSPB_INHERIT | SHGVSPB_PERUSER)))
1428
1429 if ((m_dwVspbFlags & SHGVSPB_ROAM) && (dwVspbFlags & SHGVSPB_PERFOLDER))
1431
1433}
HKEY WINAPI SHGetShellKey(DWORD flags, LPCWSTR sub_key, BOOL create)
Definition: ordinal.c:4506
@ SHKEY_Root_HKLM
Definition: ordinal.c:2805
@ SHKEY_Key_ShellNoRoam
Definition: ordinal.c:2808
@ SHKEY_Root_HKCU
Definition: ordinal.c:2804
@ SHKEY_Key_Shell
Definition: ordinal.c:2807

Referenced by _CreateBag(), _FindNearestInheritBag(), and _PruneMRUTree().

◆ _GetMRUSize()

UINT CViewStatePropertyBag::_GetMRUSize ( HKEY  hKey)
protected

Definition at line 1435 of file propbag.cpp.

1436{
1437 DWORD dwValue, cbValue = sizeof(dwValue);
1438
1439 if (SHGetValueW(hKey, NULL, L"BagMRU Size", NULL, &dwValue, &cbValue) != ERROR_SUCCESS)
1440 return 400; // The default size of the MRU (most recently used) list
1441
1442 return (UINT)dwValue;
1443}
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by _GetMRUSlots().

◆ _GetMRUSlot()

HRESULT CViewStatePropertyBag::_GetMRUSlot ( LPCITEMIDLIST  pidl,
DWORD  dwMode,
HKEY  hKey,
UINT pSlot 
)
protected

Definition at line 1475 of file propbag.cpp.

1476{
1477 UINT cSlots;
1478 return _GetMRUSlots(pidl, dwMode, hKey, pSlot, 1, &cSlots);
1479}

Referenced by _GetRegKey().

◆ _GetMRUSlots()

HRESULT CViewStatePropertyBag::_GetMRUSlots ( LPCITEMIDLIST  pidl,
DWORD  dwMode,
HKEY  hKey,
UINT puSlots,
UINT  cSlots,
UINT pcSlots 
)
protected

Definition at line 1446 of file propbag.cpp.

1453{
1454 CComPtr<IMruPidlList> pMruList;
1455 HRESULT hr = ::CoCreateInstance(CLSID_MruPidlList, NULL, CLSCTX_INPROC_SERVER,
1456 IID_IMruPidlList, (void**)&pMruList);
1457 if (FAILED(hr))
1458 return hr;
1459
1460 UINT cMRUSize = _GetMRUSize(hKey);
1461 hr = pMruList->InitList(cMRUSize, hKey, L"BagMRU");
1462 if (FAILED(hr))
1463 return hr;
1464
1465 hr = pMruList->QueryPidl(pidl, cSlots, puSlots, pcSlots);
1466 if (hr == S_OK && MODE_CAN_WRITE(dwMode))
1467 hr = pMruList->UsePidl(pidl, puSlots);
1468 else if (cSlots == 1)
1469 hr = E_FAIL;
1470
1471 return hr;
1472}
UINT _GetMRUSize(HKEY hKey)
Definition: propbag.cpp:1435
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:52

Referenced by _FindNearestInheritBag(), and _GetMRUSlot().

◆ _GetRegKey()

HRESULT CViewStatePropertyBag::_GetRegKey ( LPCITEMIDLIST  pidl,
LPCWSTR  pszBagName,
DWORD  dwFlags,
DWORD  dwMode,
HKEY  hKey,
LPWSTR  pszDest,
INT  cchDest 
)
protected

Definition at line 1482 of file propbag.cpp.

1490{
1491 HRESULT hr = S_OK;
1492 UINT nSlot;
1493
1494 if (dwFlags & (SHGVSPB_INHERIT | SHGVSPB_PERFOLDER))
1495 {
1496 hr = _GetMRUSlot(pidl, dwMode, hKey, &nSlot);
1497 if (SUCCEEDED(hr))
1498 {
1499 if (dwFlags & SHGVSPB_INHERIT)
1500 StringCchPrintfW(pszDest, cchDest, L"Bags\\%d\\%s\\Inherit", nSlot, pszBagName);
1501 else
1502 StringCchPrintfW(pszDest, cchDest, L"Bags\\%d\\%s", nSlot, pszBagName);
1503 }
1504 }
1505 else
1506 {
1507 StringCchPrintfW(pszDest, cchDest, L"Bags\\AllFolders\\%s", pszBagName);
1508 }
1509
1510 return hr;
1511}
HRESULT _GetMRUSlot(LPCITEMIDLIST pidl, DWORD dwMode, HKEY hKey, UINT *pSlot)
Definition: propbag.cpp:1475
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by _CreateBag().

◆ _IsSamePidl()

BOOL CViewStatePropertyBag::_IsSamePidl ( LPCITEMIDLIST  pidlOther) const
protected

Definition at line 1339 of file propbag.cpp.

1340{
1341 if (!pidlOther && !m_pidl)
1342 return TRUE;
1343
1344 return (pidlOther && m_pidl && ILIsEqual(pidlOther, m_pidl));
1345}
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:539

Referenced by IsSameBag().

◆ _IsSystemFolder()

BOOL CViewStatePropertyBag::_IsSystemFolder ( ) const
protected

Definition at line 1352 of file propbag.cpp.

1353{
1354 LPCITEMIDLIST ppidlLast;
1356
1357 HRESULT hr = SHBindToParent(m_pidl, IID_IShellFolder, (void **)&psf, &ppidlLast);
1358 if (FAILED(hr))
1359 return FALSE;
1360
1361 WIN32_FIND_DATAW FindData;
1362 hr = SHGetDataFromIDListW(psf, ppidlLast, SHGDFIL_FINDDATA, &FindData, sizeof(FindData));
1363 if (FAILED(hr))
1364 return FALSE;
1365
1366 return PathIsSystemFolderW(NULL, FindData.dwFileAttributes);
1367}
#define FALSE
Definition: types.h:117
BOOL WINAPI PathIsSystemFolderW(LPCWSTR lpszPath, DWORD dwAttrib)
Definition: path.c:2218
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1352
HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len)
Definition: pidl.c:1212
#define SHGDFIL_FINDDATA
Definition: shlobj.h:1443
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42

Referenced by _EnsureFolderDefaultsBag().

◆ _PruneMRUTree()

void CViewStatePropertyBag::_PruneMRUTree ( )
protected

Definition at line 1795 of file propbag.cpp.

1796{
1797 HKEY hKey = _GetHKey(SHGVSPB_INHERIT);
1798 if (!hKey)
1799 return;
1800
1801 CComPtr<IMruPidlList> pMruList;
1802 HRESULT hr = ::CoCreateInstance(CLSID_MruPidlList, NULL, CLSCTX_INPROC_SERVER,
1803 IID_IMruPidlList, (void**)&pMruList);
1804 if (SUCCEEDED(hr))
1805 {
1806 hr = pMruList->InitList(200, hKey, L"BagMRU");
1807 if (SUCCEEDED(hr))
1808 pMruList->PruneKids(m_pidl);
1809 }
1810
1812}

Referenced by _EnsureWriteBag().

◆ _ReadFolderDefaultsBag()

HRESULT CViewStatePropertyBag::_ReadFolderDefaultsBag ( LPCWSTR  pszPropName,
VARIANT pvari,
IErrorLog pErrorLog 
)
protected

Definition at line 1735 of file propbag.cpp.

1739{
1741 return E_FAIL;
1742
1743 return m_pFolderDefaultsBag->Read(pszPropName, pvari, pErrorLog);
1744}
BOOL _EnsureFolderDefaultsBag(DWORD dwMode, REFIID riid)
Definition: propbag.cpp:1662
const GUID IID_IPropertyBag

Referenced by Read().

◆ _ReadGlobalDefaultsBag()

HRESULT CViewStatePropertyBag::_ReadGlobalDefaultsBag ( LPCWSTR  pszPropName,
VARIANT pvari,
IErrorLog pErrorLog 
)
protected

Definition at line 1747 of file propbag.cpp.

1751{
1753 return E_FAIL;
1754
1755 return m_pGlobalDefaultsBag->Read(pszPropName, pvari, pErrorLog);
1756}
BOOL _EnsureGlobalDefaultsBag(DWORD dwMode, REFIID riid)
Definition: propbag.cpp:1676

Referenced by Read().

◆ _ReadInheritBag()

HRESULT CViewStatePropertyBag::_ReadInheritBag ( LPCWSTR  pszPropName,
VARIANT pvari,
IErrorLog pErrorLog 
)
protected

Definition at line 1699 of file propbag.cpp.

1703{
1705 return E_FAIL;
1706
1707 return m_pInheritBag->Read(pszPropName, pvari, pErrorLog);
1708}
BOOL _EnsureInheritBag(DWORD dwMode, REFIID riid)
Definition: propbag.cpp:1632

Referenced by Read().

◆ _ReadPidlBag()

HRESULT CViewStatePropertyBag::_ReadPidlBag ( LPCWSTR  pszPropName,
VARIANT pvari,
IErrorLog pErrorLog 
)
protected

Definition at line 1687 of file propbag.cpp.

1691{
1693 return E_FAIL;
1694
1695 return m_pPidlBag->Read(pszPropName, pvari, pErrorLog);
1696}
BOOL _EnsurePidlBag(DWORD dwMode, REFIID riid)
Definition: propbag.cpp:1622

Referenced by Read().

◆ _ReadUpgradeBag()

HRESULT CViewStatePropertyBag::_ReadUpgradeBag ( LPCWSTR  pszPropName,
VARIANT pvari,
IErrorLog pErrorLog 
)
protected

Definition at line 1711 of file propbag.cpp.

1715{
1717 return E_FAIL;
1718
1719 return m_pUpgradeBag->Read(pszPropName, pvari, pErrorLog);
1720}
BOOL _EnsureUpgradeBag(DWORD dwMode, REFIID riid)
Definition: propbag.cpp:1642

Referenced by Read().

◆ _ReadUserDefaultsBag()

HRESULT CViewStatePropertyBag::_ReadUserDefaultsBag ( LPCWSTR  pszPropName,
VARIANT pvari,
IErrorLog pErrorLog 
)
protected

Definition at line 1723 of file propbag.cpp.

1727{
1729 return E_FAIL;
1730
1731 return m_pUserDefaultsBag->Read(pszPropName, pvari, pErrorLog);
1732}
BOOL _EnsureUserDefaultsBag(DWORD dwMode, REFIID riid)
Definition: propbag.cpp:1652

Referenced by Read().

◆ _ResetTryAgainFlag()

void CViewStatePropertyBag::_ResetTryAgainFlag ( )
protected

Definition at line 1408 of file propbag.cpp.

1409{
1410 if (m_dwVspbFlags & SHGVSPB_NOAUTODEFAULTS)
1411 m_bReadBag = FALSE;
1412 else if ((m_dwVspbFlags & SHGVSPB_FOLDER) == SHGVSPB_FOLDER)
1413 m_bPidlBag = FALSE;
1414 else if (m_dwVspbFlags & SHGVSPB_INHERIT)
1416 else if ((m_dwVspbFlags & SHGVSPB_USERDEFAULTS) == SHGVSPB_USERDEFAULTS)
1418 else if ((m_dwVspbFlags & SHGVSPB_ALLUSERS) && (m_dwVspbFlags & SHGVSPB_PERFOLDER))
1420 else if ((m_dwVspbFlags & SHGVSPB_GLOBALDEAFAULTS) == SHGVSPB_GLOBALDEAFAULTS)
1422}

Referenced by _EnsureWriteBag().

◆ Init()

HRESULT CViewStatePropertyBag::Init ( _In_opt_ LPCITEMIDLIST  pidl,
_In_opt_ LPCWSTR  pszPath,
_In_ DWORD  dwVspbFlags 
)

Definition at line 1315 of file propbag.cpp.

1319{
1320 if (pidl)
1321 {
1322 m_pidl = ILClone(pidl);
1323 if (!m_pidl)
1324 return E_OUTOFMEMORY;
1325 }
1326
1327 if (pszPath)
1328 {
1329 m_pszPath = StrDupW(pszPath);
1330 if (!m_pszPath)
1331 return E_OUTOFMEMORY;
1332
1333 m_dwVspbFlags = dwVspbFlags;
1334 }
1335
1336 return S_OK;
1337}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
LPWSTR WINAPI StrDupW(LPCWSTR lpszStr)
Definition: string.c:1089
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228

◆ IsSameBag()

BOOL CViewStatePropertyBag::IsSameBag ( LPCITEMIDLIST  pidl,
LPCWSTR  pszPath,
DWORD  dwVspbFlags 
) const

Definition at line 1347 of file propbag.cpp.

1348{
1349 return (dwVspbFlags == m_dwVspbFlags && StrCmpW(pszPath, m_pszPath) == 0 && _IsSamePidl(pidl));
1350}
BOOL _IsSamePidl(LPCITEMIDLIST pidlOther) const
Definition: propbag.cpp:1339

◆ Read()

STDMETHODIMP CViewStatePropertyBag::Read ( _In_z_ LPCWSTR  pszPropName,
_Inout_ VARIANT pvari,
_Inout_opt_ IErrorLog pErrorLog 
)
override

Definition at line 1759 of file propbag.cpp.

1763{
1764 if ((m_dwVspbFlags & SHGVSPB_NOAUTODEFAULTS) || (m_dwVspbFlags & SHGVSPB_INHERIT))
1765 {
1767 return E_FAIL;
1768
1769 return m_pReadBag->Read(pszPropName, pvari, pErrorLog);
1770 }
1771
1772 HRESULT hr = _ReadPidlBag(pszPropName, pvari, pErrorLog);
1773 if (SUCCEEDED(hr))
1774 return hr;
1775
1776 hr = _ReadInheritBag(pszPropName, pvari, pErrorLog);
1777 if (SUCCEEDED(hr))
1778 return hr;
1779
1780 hr = _ReadUpgradeBag(pszPropName, pvari, pErrorLog);
1781 if (SUCCEEDED(hr))
1782 return hr;
1783
1784 hr = _ReadUserDefaultsBag(pszPropName, pvari, pErrorLog);
1785 if (SUCCEEDED(hr))
1786 return hr;
1787
1788 hr = _ReadFolderDefaultsBag(pszPropName, pvari, pErrorLog);
1789 if (SUCCEEDED(hr))
1790 return hr;
1791
1792 return _ReadGlobalDefaultsBag(pszPropName, pvari, pErrorLog);
1793}
HRESULT _ReadGlobalDefaultsBag(LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
Definition: propbag.cpp:1747
HRESULT _ReadInheritBag(LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
Definition: propbag.cpp:1699
BOOL _EnsureReadBag(DWORD dwMode, REFIID riid)
Definition: propbag.cpp:1612
HRESULT _ReadPidlBag(LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
Definition: propbag.cpp:1687
HRESULT _ReadFolderDefaultsBag(LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
Definition: propbag.cpp:1735
HRESULT _ReadUpgradeBag(LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
Definition: propbag.cpp:1711
HRESULT _ReadUserDefaultsBag(LPCWSTR pszPropName, VARIANT *pvari, IErrorLog *pErrorLog)
Definition: propbag.cpp:1723

◆ Write()

STDMETHODIMP CViewStatePropertyBag::Write ( _In_z_ LPCWSTR  pszPropName,
_In_ VARIANT pvari 
)
override

Definition at line 1830 of file propbag.cpp.

1831{
1833 return E_FAIL;
1834
1835 return m_pWriteBag->Write(pszPropName, pvari);
1836}
BOOL _EnsureWriteBag(DWORD dwMode, REFIID riid)
Definition: propbag.cpp:1814
#define STGM_WRITE
Definition: objbase.h:918

Member Data Documentation

◆ m_bFolderDefaultsBag

BOOL CViewStatePropertyBag::m_bFolderDefaultsBag = FALSE
protected

Definition at line 1222 of file propbag.cpp.

Referenced by _EnsureFolderDefaultsBag(), and _ResetTryAgainFlag().

◆ m_bGlobalDefaultsBag

BOOL CViewStatePropertyBag::m_bGlobalDefaultsBag = FALSE
protected

Definition at line 1223 of file propbag.cpp.

Referenced by _EnsureGlobalDefaultsBag(), and _ResetTryAgainFlag().

◆ m_bInheritBag

BOOL CViewStatePropertyBag::m_bInheritBag = FALSE
protected

Definition at line 1220 of file propbag.cpp.

Referenced by _EnsureInheritBag(), and _ResetTryAgainFlag().

◆ m_bPidlBag

BOOL CViewStatePropertyBag::m_bPidlBag = FALSE
protected

Definition at line 1218 of file propbag.cpp.

Referenced by _EnsurePidlBag(), and _ResetTryAgainFlag().

◆ m_bReadBag

BOOL CViewStatePropertyBag::m_bReadBag = FALSE
protected

Definition at line 1224 of file propbag.cpp.

Referenced by _EnsureReadBag(), and _ResetTryAgainFlag().

◆ m_bUpgradeBag

BOOL CViewStatePropertyBag::m_bUpgradeBag = FALSE
protected

Definition at line 1219 of file propbag.cpp.

Referenced by _EnsureUpgradeBag().

◆ m_bUserDefaultsBag

BOOL CViewStatePropertyBag::m_bUserDefaultsBag = FALSE
protected

Definition at line 1221 of file propbag.cpp.

Referenced by _EnsureUserDefaultsBag(), and _ResetTryAgainFlag().

◆ m_bWriteBag

BOOL CViewStatePropertyBag::m_bWriteBag = FALSE
protected

Definition at line 1225 of file propbag.cpp.

Referenced by _EnsureWriteBag().

◆ m_dwVspbFlags

◆ m_pFolderDefaultsBag

CComPtr<IPropertyBag> CViewStatePropertyBag::m_pFolderDefaultsBag
protected

Definition at line 1214 of file propbag.cpp.

Referenced by _EnsureFolderDefaultsBag(), and _ReadFolderDefaultsBag().

◆ m_pGlobalDefaultsBag

CComPtr<IPropertyBag> CViewStatePropertyBag::m_pGlobalDefaultsBag
protected

Definition at line 1215 of file propbag.cpp.

Referenced by _EnsureGlobalDefaultsBag(), and _ReadGlobalDefaultsBag().

◆ m_pidl

◆ m_pInheritBag

CComPtr<IPropertyBag> CViewStatePropertyBag::m_pInheritBag
protected

Definition at line 1212 of file propbag.cpp.

Referenced by _EnsureInheritBag(), and _ReadInheritBag().

◆ m_pPidlBag

CComPtr<IPropertyBag> CViewStatePropertyBag::m_pPidlBag
protected

Definition at line 1210 of file propbag.cpp.

Referenced by _EnsurePidlBag(), and _ReadPidlBag().

◆ m_pReadBag

CComPtr<IPropertyBag> CViewStatePropertyBag::m_pReadBag
protected

Definition at line 1216 of file propbag.cpp.

Referenced by _EnsureReadBag(), and Read().

◆ m_pszPath

◆ m_pUpgradeBag

CComPtr<IPropertyBag> CViewStatePropertyBag::m_pUpgradeBag
protected

Definition at line 1211 of file propbag.cpp.

Referenced by _EnsureUpgradeBag(), and _ReadUpgradeBag().

◆ m_pUserDefaultsBag

CComPtr<IPropertyBag> CViewStatePropertyBag::m_pUserDefaultsBag
protected

Definition at line 1213 of file propbag.cpp.

Referenced by _EnsureUserDefaultsBag(), and _ReadUserDefaultsBag().

◆ m_pWriteBag

CComPtr<IPropertyBag> CViewStatePropertyBag::m_pWriteBag
protected

Definition at line 1217 of file propbag.cpp.

Referenced by _EnsureWriteBag(), and Write().


The documentation for this class was generated from the following file: