ReactOS 0.4.15-dev-7654-g6bc40d3
CDesktopUpgradePropertyBag Class Reference
Inheritance diagram for CDesktopUpgradePropertyBag:
Collaboration diagram for CDesktopUpgradePropertyBag:

Public Member Functions

 CDesktopUpgradePropertyBag ()
 
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 _AlreadyUpgraded (HKEY hKey)
 
VOID _MarkAsUpgraded (HKEY hkey)
 
HRESULT _ReadFlags (VARIANT *pvari)
 
HRESULT _ReadItemPositions (VARIANT *pvari)
 
IStream_GetOldDesktopViewStream ()
 
IStream_NewStreamFromOld (IStream *pOldStream)
 

Additional Inherited Members

- Public Types inherited from IPropertyBag
typedef IPropertyBagLPPROPERTYBAG
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Protected Attributes inherited from CBasePropertyBag
LONG m_cRefs
 
DWORD m_dwMode
 

Detailed Description

Definition at line 1010 of file propbag.cpp.

Constructor & Destructor Documentation

◆ CDesktopUpgradePropertyBag()

CDesktopUpgradePropertyBag::CDesktopUpgradePropertyBag ( )
inline

Definition at line 1021 of file propbag.cpp.

#define STGM_READ
Definition: objbase.h:917

Member Function Documentation

◆ _AlreadyUpgraded()

BOOL CDesktopUpgradePropertyBag::_AlreadyUpgraded ( HKEY  hKey)
protected

Definition at line 1041 of file propbag.cpp.

1042{
1043 // Check the existence of the value written in _MarkAsUpgraded.
1044 DWORD dwValue, cbData = sizeof(dwValue);
1045 return SHGetValueW(hKey, NULL, L"Upgrade", NULL, &dwValue, &cbData) == ERROR_SUCCESS;
1046}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
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
FxAutoRegKey hKey
#define L(x)
Definition: ntvdm.h:50

Referenced by _GetOldDesktopViewStream().

◆ _GetOldDesktopViewStream()

IStream * CDesktopUpgradePropertyBag::_GetOldDesktopViewStream ( )
protected

Definition at line 1116 of file propbag.cpp.

1117{
1118 HKEY hKey = SHGetShellKey(SHKEY_Root_HKCU, L"Streams\\Desktop", FALSE);
1119 if (!hKey)
1120 return NULL;
1121
1122 CComPtr<IStream> pOldStream;
1123 if (!_AlreadyUpgraded(hKey))
1124 {
1125 pOldStream.Attach(SHOpenRegStream2W(hKey, NULL, L"ViewView2", 0));
1126 if (pOldStream)
1127 {
1128 ULARGE_INTEGER uli;
1129 HRESULT hr = IStream_Size(pOldStream, &uli);
1130 if (SUCCEEDED(hr) && !uli.QuadPart)
1131 pOldStream.Release();
1132 }
1133
1134 if (!pOldStream)
1135 pOldStream.Attach(SHOpenRegStream2W(hKey, NULL, L"ViewView", 0));
1136
1138 }
1139
1141 return pOldStream.Detach();
1142}
#define RegCloseKey(hKey)
Definition: registry.h:49
void Release()
Definition: atlcomcli.h:170
void Attach(T *lp)
Definition: atlcomcli.h:179
T * Detach()
Definition: atlcomcli.h:186
VOID _MarkAsUpgraded(HKEY hkey)
Definition: propbag.cpp:1035
BOOL _AlreadyUpgraded(HKEY hKey)
Definition: propbag.cpp:1041
#define FALSE
Definition: types.h:117
HRESULT WINAPI IStream_Size(IStream *lpStream, ULARGE_INTEGER *lpulSize)
Definition: istream.c:661
HKEY WINAPI SHGetShellKey(DWORD flags, LPCWSTR sub_key, BOOL create)
Definition: ordinal.c:4506
#define SUCCEEDED(hr)
Definition: intsafe.h:50
@ SHKEY_Root_HKCU
Definition: ordinal.c:2804
IStream *WINAPI SHOpenRegStream2W(HKEY hKey, LPCWSTR pszSubkey, LPCWSTR pszValue, DWORD dwMode)
Definition: regstream.c:537
HRESULT hr
Definition: shlfolder.c:183
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185

Referenced by _ReadItemPositions().

◆ _MarkAsUpgraded()

VOID CDesktopUpgradePropertyBag::_MarkAsUpgraded ( HKEY  hkey)
protected

Definition at line 1035 of file propbag.cpp.

1036{
1037 DWORD dwValue = TRUE;
1038 SHSetValueW(hkey, NULL, L"Upgrade", REG_DWORD, &dwValue, sizeof(dwValue));
1039}
#define TRUE
Definition: types.h:120
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by _GetOldDesktopViewStream().

◆ _NewStreamFromOld()

IStream * CDesktopUpgradePropertyBag::_NewStreamFromOld ( IStream pOldStream)
protected

Definition at line 1076 of file propbag.cpp.

1077{
1079 HRESULT hr = pOldStream->Read(&Header, sizeof(Header), NULL);
1080 if (FAILED(hr) || Header.wMagic != 28)
1081 return NULL;
1082
1083 // Move stream pointer
1085 li.QuadPart = Header.wSize - sizeof(Header);
1086 hr = pOldStream->Seek(li, STREAM_SEEK_CUR, NULL);
1087 if (FAILED(hr))
1088 return NULL;
1089
1090 // Get the size
1091 ULARGE_INTEGER uli;
1092 hr = IStream_Size(pOldStream, &uli);
1093 if (FAILED(hr))
1094 return NULL;
1095
1096 // Create new stream and attach
1097 CComPtr<IStream> pNewStream;
1098 pNewStream.Attach(SHCreateMemStream(NULL, 0));
1099 if (!pNewStream)
1100 return NULL;
1101
1102 // Subtract Header.wSize from the size
1103 uli.QuadPart -= Header.wSize;
1104
1105 // Copy to pNewStream
1106 hr = pOldStream->CopyTo(pNewStream, uli, NULL, NULL);
1107 if (FAILED(hr))
1108 return NULL;
1109
1110 li.QuadPart = 0;
1111 pNewStream->Seek(li, STREAM_SEEK_SET, NULL);
1112
1113 return pNewStream.Detach();
1114}
Definition: Header.h:9
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
HRESULT Read([out, size_is(cb), length_is(*pcbRead)] void *pv, [in] ULONG cb, [out] ULONG *pcbRead)
HRESULT CopyTo([in, unique] IStream *pstm, [in] ULARGE_INTEGER cb, [out] ULARGE_INTEGER *pcbRead, [out] ULARGE_INTEGER *pcbWritten)
HRESULT Seek([in] LARGE_INTEGER dlibMove, [in] DWORD dwOrigin, [out] ULARGE_INTEGER *plibNewPosition)
#define FAILED(hr)
Definition: intsafe.h:51
IStream *WINAPI SHCreateMemStream(const BYTE *lpbData, UINT dwDataLen)
Definition: regstream.c:652
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by _ReadItemPositions().

◆ _ReadFlags()

HRESULT CDesktopUpgradePropertyBag::_ReadFlags ( VARIANT pvari)
protected

Definition at line 1050 of file propbag.cpp.

1051{
1053 DWORD cbValue = sizeof(Flags);
1055 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\DeskView",
1056 L"Settings",
1057 NULL,
1058 &Flags,
1059 &cbValue) != ERROR_SUCCESS || cbValue < sizeof(Flags))
1060 {
1061 return E_FAIL;
1062 }
1063
1064 V_UINT(pvari) = ((UINT)(Flags >> 32)) | 0x220; // FIXME: Magic number
1065 V_VT(pvari) = VT_UINT;
1066 return S_OK;
1067}
#define E_FAIL
Definition: ddrawi.h:102
@ VT_UINT
Definition: compat.h:2317
#define S_OK
Definition: intsafe.h:52
unsigned int UINT
Definition: ndis.h:50
#define V_VT(A)
Definition: oleauto.h:211
#define V_UINT(A)
Definition: oleauto.h:264
DWORDLONG DESKVIEW_FLAGS
Definition: propbag.cpp:1048
#define HKEY_CURRENT_USER
Definition: winreg.h:11
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by Read().

◆ _ReadItemPositions()

HRESULT CDesktopUpgradePropertyBag::_ReadItemPositions ( VARIANT pvari)
protected

Definition at line 1144 of file propbag.cpp.

1145{
1146 CComPtr<IStream> pOldStream;
1147 pOldStream.Attach(_GetOldDesktopViewStream());
1148 if (!pOldStream)
1149 return E_FAIL;
1150
1151 HRESULT hr = E_FAIL;
1152 IStream *pNewStream = _NewStreamFromOld(pOldStream);
1153 if (pNewStream)
1154 {
1155 V_UNKNOWN(pvari) = pNewStream;
1156 V_VT(pvari) = VT_UNKNOWN;
1157 hr = S_OK;
1158 }
1159
1160 return hr;
1161}
IStream * _GetOldDesktopViewStream()
Definition: propbag.cpp:1116
IStream * _NewStreamFromOld(IStream *pOldStream)
Definition: propbag.cpp:1076
@ VT_UNKNOWN
Definition: compat.h:2308
#define V_UNKNOWN(A)
Definition: oleauto.h:281

Referenced by Read().

◆ Read()

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

Definition at line 1164 of file propbag.cpp.

1168{
1169 UNREFERENCED_PARAMETER(pErrorLog);
1170
1171 VARTYPE vt = V_VT(pvari);
1172
1173 HRESULT hr = E_FAIL;
1174 if (StrCmpW(L"FFlags", pszPropName) == 0)
1175 hr = _ReadFlags(pvari);
1176 else if (StrCmpNW(L"ItemPos", pszPropName, 7) == 0)
1177 hr = _ReadItemPositions(pvari);
1178
1179 if (FAILED(hr))
1180 {
1181 ::VariantInit(pvari);
1182 return hr;
1183 }
1184
1185 return ::VariantChangeType(pvari, pvari, 0, vt);
1186}
HRESULT _ReadFlags(VARIANT *pvari)
Definition: propbag.cpp:1050
HRESULT _ReadItemPositions(VARIANT *pvari)
Definition: propbag.cpp:1144
INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:504
unsigned short VARTYPE
Definition: compat.h:2254
static REFPROPVARIANT PROPVAR_CHANGE_FLAGS VARTYPE vt
Definition: suminfo.c:86
int WINAPI StrCmpW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:434
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:568

◆ Write()

STDMETHODIMP CDesktopUpgradePropertyBag::Write ( _In_z_ LPCWSTR  pszPropName,
_In_ VARIANT pvari 
)
inlineoverride

Definition at line 1028 of file propbag.cpp.

1029 {
1030 ERR("%p: %s: Read-only\n", this, debugstr_w(pszPropName));
1031 return E_NOTIMPL;
1032 }
#define ERR(fmt,...)
Definition: debug.h:110
#define E_NOTIMPL
Definition: ddrawi.h:99
#define debugstr_w
Definition: kernel32.h:32

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