ReactOS 0.4.15-dev-8145-ga541a46
RunOnceExSection Class Reference

#include <registry.h>

Collaboration diagram for RunOnceExSection:

Public Member Functions

 RunOnceExSection (_In_ CRegKeyEx &hParentKey, _In_ const CStringW &lpSubKeyName)
 
 RunOnceExSection (_In_ const RunOnceExSection &Section)
 
BOOL CloseAndDelete (_In_ CRegKeyEx &hParentKey)
 
UINT GetEntryCnt () const
 
BOOL Exec (_Inout_ UINT &iCompleteCnt, _In_ const UINT iTotalCnt)
 

Public Attributes

BOOL m_bSuccess
 
ATL::CStringW m_SectionTitle
 
CSimpleArray< RunOnceExEntrym_EntryList
 

Private Member Functions

BOOL HandleValue (_In_ CRegKeyEx &hKey, _In_ const CStringW &ValueName)
 

Private Attributes

ATL::CStringW m_SectionName
 
CRegKeyEx m_RegKey
 

Friends

class RunOnceExInstance
 
int RunOnceExSectionCmp (_In_ const void *a, _In_ const void *b)
 

Detailed Description

Definition at line 51 of file registry.h.

Constructor & Destructor Documentation

◆ RunOnceExSection() [1/2]

RunOnceExSection::RunOnceExSection ( _In_ CRegKeyEx hParentKey,
_In_ const CStringW &  lpSubKeyName 
)

Definition at line 132 of file registry.cpp.

134 :
135 m_SectionName(lpSubKeyName)
136{
138 DWORD dwValueNum;
139 DWORD dwMaxValueNameLen;
142
143 if (m_RegKey.Open(hParentKey, lpSubKeyName) != ERROR_SUCCESS)
144 return;
145
147 &dwValueNum, &dwMaxValueNameLen,
148 NULL, NULL, NULL);
149 if (Error != ERROR_SUCCESS)
150 return;
151
152 for (DWORD i = 0; i < dwValueNum; i++)
153 {
154 LPWSTR szValueName;
155 DWORD dwcchName = dwMaxValueNameLen + 1;
156
157 szValueName = ValueName.GetBuffer(dwMaxValueNameLen + 1);
158 Error = m_RegKey.EnumValueName(i, szValueName, &dwcchName);
159 ValueName.ReleaseBuffer();
160
161 if (Error != ERROR_SUCCESS)
162 {
163 // TODO: error handling
164 return;
165 }
166
168 return;
169 }
170
171 // Sort entries by name in string order.
174
176 return;
177}
BOOL Error
Definition: chkdsk.c:66
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE) noexcept
Definition: atlbase.h:1173
int GetSize() const
Definition: atlsimpcoll.h:104
LONG EnumValueName(_In_ DWORD iIndex, _Out_ LPTSTR pszName, _Inout_ LPDWORD pnNameLength)
Definition: registry.cpp:12
CSimpleArray< RunOnceExEntry > m_EntryList
Definition: registry.h:64
BOOL HandleValue(_In_ CRegKeyEx &hKey, _In_ const CStringW &ValueName)
Definition: registry.cpp:85
ATL::CStringW m_SectionName
Definition: registry.h:54
CRegKeyEx m_RegKey
Definition: registry.h:55
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
int RunOnceExEntryCmp(_In_ const void *a, _In_ const void *b)
Definition: registry.cpp:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
CAtlStringW CStringW
Definition: atlstr.h:130
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ RunOnceExSection() [2/2]

RunOnceExSection::RunOnceExSection ( _In_ const RunOnceExSection Section)

Definition at line 180 of file registry.cpp.

180 :
181 m_SectionName(Section.m_SectionName),
182 m_bSuccess(Section.m_bSuccess),
183 m_SectionTitle(Section.m_SectionTitle),
184 m_EntryList(Section.m_EntryList)
185{
186 m_RegKey.Attach(Section.m_RegKey);
187}
void Attach(HKEY hKey) noexcept
Definition: atlbase.h:1151
ATL::CStringW m_SectionTitle
Definition: registry.h:63

Member Function Documentation

◆ CloseAndDelete()

BOOL RunOnceExSection::CloseAndDelete ( _In_ CRegKeyEx hParentKey)

Definition at line 189 of file registry.cpp.

191{
192 m_RegKey.Close();
193 return hParentKey.RecurseDeleteKey(m_SectionName) == ERROR_SUCCESS;
194}
LONG Close() noexcept
Definition: atlbase.h:1156

◆ Exec()

BOOL RunOnceExSection::Exec ( _Inout_ UINT iCompleteCnt,
_In_ const UINT  iTotalCnt 
)

Definition at line 201 of file registry.cpp.

204{
206
207 for (int i = 0; i < m_EntryList.GetSize(); i++)
208 {
209 m_EntryList[i].Delete(m_RegKey);
210 bSuccess &= m_EntryList[i].Exec();
211 iCompleteCnt++;
212 // TODO: the meaning of the third param is still unknown, seems it's always 0.
213 if (g_Callback)
214 g_Callback(iCompleteCnt, iTotalCnt, NULL);
215 }
216 return bSuccess;
217}
static BOOLEAN bSuccess
Definition: drive.cpp:433
unsigned int BOOL
Definition: ntddk_ex.h:94
RUNONCEEX_CALLBACK g_Callback
Definition: iernonce.cpp:11

◆ GetEntryCnt()

UINT RunOnceExSection::GetEntryCnt ( ) const

Definition at line 196 of file registry.cpp.

197{
198 return m_EntryList.GetSize();
199}

◆ HandleValue()

BOOL RunOnceExSection::HandleValue ( _In_ CRegKeyEx hKey,
_In_ const CStringW &  ValueName 
)
private

Definition at line 85 of file registry.cpp.

88{
89 DWORD dwType;
90 DWORD cbData;
91
92 // Query data size
93 if (hKey.QueryValue(ValueName, &dwType, NULL, &cbData) != ERROR_SUCCESS)
94 return FALSE;
95
96 // Validate its format and size.
97 if (dwType != REG_SZ)
98 return TRUE;
99
100 if (cbData % sizeof(WCHAR) != 0)
101 return FALSE;
102
104 LPWSTR szBuffer = Buffer.GetBuffer((cbData / sizeof(WCHAR)) + 1);
105
106 if (hKey.QueryValue(ValueName, &dwType, szBuffer, &cbData) != ERROR_SUCCESS)
107 {
108 Buffer.ReleaseBuffer();
109 return FALSE;
110 }
111 szBuffer[cbData / sizeof(WCHAR)] = L'\0';
112 Buffer.ReleaseBuffer();
113
114 CStringW ExpandStr;
115 DWORD dwcchExpand = ExpandEnvironmentStringsW(Buffer, NULL, 0);
116 ExpandEnvironmentStringsW(Buffer, ExpandStr.GetBuffer(dwcchExpand + 1), dwcchExpand);
117 ExpandStr.ReleaseBuffer();
118
119 if (ValueName.IsEmpty())
120 {
121 // The default value specifies the section title.
123 }
124 else
125 {
127 }
128
129 return TRUE;
130}
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
Definition: bufpool.h:45
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
FxAutoRegKey hKey
#define REG_SZ
Definition: layer.c:22
#define L(x)
Definition: ntvdm.h:50
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by RunOnceExSection().

Friends And Related Function Documentation

◆ RunOnceExInstance

friend class RunOnceExInstance
friend

Definition at line 84 of file registry.h.

◆ RunOnceExSectionCmp

int RunOnceExSectionCmp ( _In_ const void a,
_In_ const void b 
)
friend

Definition at line 219 of file registry.cpp.

222{
225}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Member Data Documentation

◆ m_bSuccess

BOOL RunOnceExSection::m_bSuccess

Definition at line 62 of file registry.h.

Referenced by RunOnceExInstance::HandleSubKey(), and RunOnceExSection().

◆ m_EntryList

CSimpleArray<RunOnceExEntry> RunOnceExSection::m_EntryList

Definition at line 64 of file registry.h.

Referenced by Exec(), GetEntryCnt(), HandleValue(), and RunOnceExSection().

◆ m_RegKey

CRegKeyEx RunOnceExSection::m_RegKey
private

Definition at line 55 of file registry.h.

Referenced by CloseAndDelete(), Exec(), RunOnceExInstance::HandleSubKey(), and RunOnceExSection().

◆ m_SectionName

ATL::CStringW RunOnceExSection::m_SectionName
private

Definition at line 54 of file registry.h.

Referenced by CloseAndDelete().

◆ m_SectionTitle

ATL::CStringW RunOnceExSection::m_SectionTitle

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