ReactOS 0.4.16-dev-109-gf4cb10f
RunOnceExInstance Class Reference

#include <registry.h>

Collaboration diagram for RunOnceExInstance:

Public Member Functions

 RunOnceExInstance (_In_ HKEY BaseKey)
 
BOOL Exec (_In_opt_ HWND hwnd)
 
BOOL Run (_In_ BOOL bSilence)
 

Public Attributes

BOOL m_bSuccess
 
CSimpleArray< RunOnceExSectionm_SectionList
 
CStringW m_Title
 
DWORD m_dwFlags
 
BOOL m_bShowDialog
 

Private Member Functions

BOOL HandleSubKey (_In_ CRegKeyEx &hKey, _In_ const CStringW &SubKeyName)
 

Private Attributes

CRegKeyEx m_RegKey
 

Detailed Description

Definition at line 87 of file registry.h.

Constructor & Destructor Documentation

◆ RunOnceExInstance()

RunOnceExInstance::RunOnceExInstance ( _In_ HKEY  BaseKey)

Definition at line 227 of file registry.cpp.

228{
230 DWORD dwSubKeyNum;
231 DWORD dwMaxSubKeyNameLen;
234
235 Error = m_RegKey.Open(BaseKey,
236 L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx\\");
237 if (Error != ERROR_SUCCESS)
238 {
239 return;
240 }
241
242 ULONG cchTitle;
243 Error = m_RegKey.QueryStringValue(L"Title", NULL, &cchTitle);
244 if (Error == ERROR_SUCCESS)
245 {
246 Error = m_RegKey.QueryStringValue(L"Title", m_Title.GetBuffer(cchTitle + 1), &cchTitle);
247 m_Title.ReleaseBuffer();
248 if (Error != ERROR_SUCCESS)
249 return;
250 }
251
253 if (Error != ERROR_SUCCESS)
254 {
255 m_dwFlags = 0;
256 }
257
259 &dwSubKeyNum, &dwMaxSubKeyNameLen,
260 NULL, NULL, NULL, NULL, NULL, NULL);
261 if (Error != ERROR_SUCCESS)
262 return;
263
265
266 for (DWORD i = 0; i < dwSubKeyNum; i++)
267 {
268 LPWSTR szSubKeyName;
269 DWORD dwcchName = dwMaxSubKeyNameLen + 1;
270
271 szSubKeyName = SubKeyName.GetBuffer(dwMaxSubKeyNameLen + 1);
272 Error = m_RegKey.EnumKey(i, szSubKeyName, &dwcchName);
273 SubKeyName.ReleaseBuffer();
274
275 if (Error != ERROR_SUCCESS)
276 {
277 // TODO: error handling
278 return;
279 }
280
282 return;
283 }
284
285 // Sort sections by name in string order.
288
290 return;
291}
BOOL Error
Definition: chkdsk.c:66
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE) noexcept
Definition: atlbase.h:1173
LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars) noexcept
Definition: atlbase.h:1240
LONG QueryDWORDValue(LPCTSTR pszValueName, DWORD &dwValue) noexcept
Definition: atlbase.h:1217
LONG EnumKey(DWORD iIndex, LPTSTR pszName, LPDWORD pnNameLength, FILETIME *pftLastWriteTime=NULL) noexcept
Definition: atlbase.h:1421
int GetSize() const
Definition: atlsimpcoll.h:104
BOOL HandleSubKey(_In_ CRegKeyEx &hKey, _In_ const CStringW &SubKeyName)
Definition: registry.cpp:339
CStringW m_Title
Definition: registry.h:99
CSimpleArray< RunOnceExSection > m_SectionList
Definition: registry.h:98
CRegKeyEx m_RegKey
Definition: registry.h:90
#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 RunOnceExSectionCmp(_In_ const void *a, _In_ const void *b)
Definition: registry.cpp:219
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
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4725
#define L(x)
Definition: ntvdm.h:50
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 *))
uint32_t ULONG
Definition: typedefs.h:59
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Member Function Documentation

◆ Exec()

BOOL RunOnceExInstance::Exec ( _In_opt_ HWND  hwnd)

Definition at line 293 of file registry.cpp.

294{
296
297 UINT TotalCnt = 0;
298 UINT CompleteCnt = 0;
299 for (int i = 0; i < m_SectionList.GetSize(); i++)
300 {
301 TotalCnt += m_SectionList[i].GetEntryCnt();
302 }
303
304 // Execute items from registry one by one, and remove them.
305 for (int i = 0; i < m_SectionList.GetSize(); i++)
306 {
307 if (hwnd)
309
310 bSuccess &= m_SectionList[i].Exec(CompleteCnt, TotalCnt);
311 m_SectionList[i].CloseAndDelete(m_RegKey);
312 }
313
314 m_RegKey.DeleteValue(L"Title");
315 m_RegKey.DeleteValue(L"Flags");
316
317 // Notify the dialog all sections are handled.
318 if (hwnd)
320 return bSuccess;
321}
LONG DeleteValue(LPCTSTR lpszValue) noexcept
Definition: atlbase.h:1401
#define WM_SETINDEX
Definition: dialog.h:18
static BOOLEAN bSuccess
Definition: drive.cpp:477
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned int UINT
Definition: ndis.h:50
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by Run(), and RunOnceExExecThread().

◆ HandleSubKey()

BOOL RunOnceExInstance::HandleSubKey ( _In_ CRegKeyEx hKey,
_In_ const CStringW &  SubKeyName 
)
private

Definition at line 339 of file registry.cpp.

342{
344 if (!Section.m_bSuccess)
345 {
346 return FALSE;
347 }
348
349 if (!Section.m_SectionTitle.IsEmpty())
350 {
352 }
353 m_SectionList.Add(Section);
354
355 // The copy constructor of RunOnceExSection didn't detach
356 // the m_RegKey while it's attached to the one in the array.
357 // So we have to detach it manually.
358 Section.m_RegKey.Detach();
359 return TRUE;
360}
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
FxAutoRegKey hKey

Referenced by RunOnceExInstance().

◆ Run()

BOOL RunOnceExInstance::Run ( _In_ BOOL  bSilence)

Definition at line 323 of file registry.cpp.

324{
325 if (bSilence ||
328 {
329 return Exec(NULL);
330 }
331 else
332 {
333 // The dialog is responsible to create a thread and execute.
334 ProgressDlg dlg(*this);
335 return dlg.RunDialogBox();
336 }
337}
BOOL Exec(_In_opt_ HWND hwnd)
Definition: registry.cpp:293
#define FLAGS_NO_STAT_DIALOG
Definition: registry.h:16

Member Data Documentation

◆ m_bShowDialog

BOOL RunOnceExInstance::m_bShowDialog

Definition at line 101 of file registry.h.

Referenced by HandleSubKey(), Run(), and RunOnceExInstance().

◆ m_bSuccess

BOOL RunOnceExInstance::m_bSuccess

Definition at line 97 of file registry.h.

Referenced by RunOnceExInstance().

◆ m_dwFlags

DWORD RunOnceExInstance::m_dwFlags

Definition at line 100 of file registry.h.

Referenced by Run(), and RunOnceExInstance().

◆ m_RegKey

CRegKeyEx RunOnceExInstance::m_RegKey
private

Definition at line 90 of file registry.h.

Referenced by Exec(), and RunOnceExInstance().

◆ m_SectionList

CSimpleArray<RunOnceExSection> RunOnceExInstance::m_SectionList

◆ m_Title

CStringW RunOnceExInstance::m_Title

Definition at line 99 of file registry.h.

Referenced by ProgressDlg::ProcessWindowMessage(), and RunOnceExInstance().


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