ReactOS  0.4.15-dev-5492-g47f3a4e
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 {
229  m_bSuccess = FALSE;
230  DWORD dwSubKeyNum;
231  DWORD dwMaxSubKeyNameLen;
232  LSTATUS Error;
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 
289  m_bSuccess = TRUE;
290  return;
291 }
BOOL HandleSubKey(_In_ CRegKeyEx &hKey, _In_ const CStringW &SubKeyName)
Definition: registry.cpp:339
#define ERROR_SUCCESS
Definition: deptool.c:10
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4723
CSimpleArray< RunOnceExSection > m_SectionList
Definition: registry.h:98
#define TRUE
Definition: types.h:120
CRegKeyEx m_RegKey
Definition: registry.h:90
int GetSize() const
Definition: atlsimpcoll.h:104
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
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 *))
LONG QueryDWORDValue(LPCTSTR pszValueName, DWORD &dwValue)
Definition: atlbase.h:1128
LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired=KEY_READ|KEY_WRITE)
Definition: atlbase.h:1072
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG QueryStringValue(LPCTSTR pszValueName, LPTSTR pszValue, ULONG *pnChars)
Definition: atlbase.h:1151
BOOL Error
Definition: chkdsk.c:66
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
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:3690
LONG EnumKey(DWORD iIndex, LPTSTR pszName, LPDWORD pnNameLength, FILETIME *pftLastWriteTime=NULL)
Definition: atlbase.h:1332
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
int RunOnceExSectionCmp(_In_ const void *a, _In_ const void *b)
Definition: registry.cpp:219
#define NULL
Definition: types.h:112
CStringW m_Title
Definition: registry.h:99
unsigned int ULONG
Definition: retypes.h:1
CAtlStringW CStringW
Definition: atlstr.h:130
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 {
295  BOOL bSuccess = TRUE;
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 }
CSimpleArray< RunOnceExSection > m_SectionList
Definition: registry.h:98
#define TRUE
Definition: types.h:120
CRegKeyEx m_RegKey
Definition: registry.h:90
int GetSize() const
Definition: atlsimpcoll.h:104
static BOOLEAN bSuccess
Definition: drive.cpp:433
#define L(x)
Definition: ntvdm.h:50
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_SETINDEX
Definition: dialog.h:18
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
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int UINT
Definition: ndis.h:50
LONG DeleteValue(LPCTSTR lpszValue)
Definition: atlbase.h:1312
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022

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 {
343  RunOnceExSection Section(hKey, SubKeyName);
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
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING SubKeyName
Definition: ndis.h:4723
CSimpleArray< RunOnceExSection > m_SectionList
Definition: registry.h:98
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
FxAutoRegKey hKey

Referenced by RunOnceExInstance().

◆ Run()

BOOL RunOnceExInstance::Run ( _In_ BOOL  bSilence)

Definition at line 323 of file registry.cpp.

324 {
325  if (bSilence ||
327  !m_bShowDialog)
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 }
#define FLAGS_NO_STAT_DIALOG
Definition: registry.h:16
#define NULL
Definition: types.h:112
BOOL Exec(_In_opt_ HWND hwnd)
Definition: registry.cpp:293

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: