ReactOS  0.4.15-dev-5499-g1341c38
CInstalledApps Class Reference

#include <installed.h>

Collaboration diagram for CInstalledApps:

Public Member Functions

BOOL Enum (INT EnumType, APPENUMPROC lpEnumProc, PVOID param)
 
VOID FreeCachedEntries ()
 

Private Attributes

ATL::CAtlList< CInstalledApplicationInfo * > m_InfoList
 

Detailed Description

Definition at line 54 of file installed.h.

Member Function Documentation

◆ Enum()

BOOL CInstalledApps::Enum ( INT  EnumType,
APPENUMPROC  lpEnumProc,
PVOID  param 
)

Definition at line 247 of file installed.cpp.

248 {
250 
253 
254  int LoopTime;
255 
256  // test if the OS is 64 bit.
257  if (IsSystem64Bit())
258  {
259  // loop for all 3 combination.
260  // note that HKEY_CURRENT_USER\Software don't have a redirect
261  // https://docs.microsoft.com/en-us/windows/win32/winprog64/shared-registry-keys#redirected-shared-and-reflected-keys-under-wow64
262  LoopTime = 3;
263  }
264  else
265  {
266  // loop for 2 combination for KEY_WOW64_32KEY only
267  LoopTime = 2;
268  }
269 
270  // loop for all combination
271  for (int i = 0; i < LoopTime; i++)
272  {
274  HKEY hKey, hSubKey;
275  LONG ItemIndex = 0;
276  ATL::CStringW szKeyName;
277 
278  if (RegOpenKeyExW(RootKeyEnum[i],
279  L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
280  NULL,
281  KEY_READ | RegSamEnum[i],
282  &hKey) != ERROR_SUCCESS)
283  {
284  return FALSE;
285  }
286 
287  while (1)
288  {
289  dwSize = MAX_PATH;
290  if (RegEnumKeyExW(hKey, ItemIndex, szKeyName.GetBuffer(MAX_PATH), &dwSize, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
291  {
292  break;
293  }
294 
295  ItemIndex++;
296 
297  szKeyName.ReleaseBuffer();
298  if (RegOpenKeyW(hKey, szKeyName, &hSubKey) == ERROR_SUCCESS)
299  {
300  DWORD dwValue = 0;
301  BOOL bIsSystemComponent = FALSE;
302 
303  dwSize = sizeof(DWORD);
304  if (RegQueryValueExW(hSubKey, L"SystemComponent", NULL, NULL, (LPBYTE)&dwValue, &dwSize) == ERROR_SUCCESS)
305  {
306  bIsSystemComponent = (dwValue == 0x1);
307  }
308  // Ignore system components
309  if (bIsSystemComponent)
310  {
311  RegCloseKey(hSubKey);
312  continue;
313  }
314 
315  BOOL bSuccess = FALSE;
316  CInstalledApplicationInfo *Info = new CInstalledApplicationInfo(RootKeyEnum[i] == HKEY_CURRENT_USER, RegSamEnum[i], hSubKey, szKeyName);
317 
318  // items without display name are ignored
319  if (Info->GetApplicationRegString(L"DisplayName", Info->szDisplayName))
320  {
321  Info->GetApplicationRegString(L"DisplayIcon", Info->szDisplayIcon);
322  Info->GetApplicationRegString(L"DisplayVersion", Info->szDisplayVersion);
323  Info->GetApplicationRegString(L"Comments", Info->szComments);
324 
325  bSuccess = TRUE;
326  }
327 
328  if (bSuccess)
329  {
330  // add to InfoList.
332 
333  // invoke callback
334  if (lpEnumProc)
335  {
336  if ((EnumType == ENUM_ALL_INSTALLED) || /* All components */
337  ((EnumType == ENUM_INSTALLED_APPLICATIONS) && (!Info->bIsUpdate)) || /* Applications only */
338  ((EnumType == ENUM_UPDATES) && (Info->bIsUpdate))) /* Updates only */
339  {
340  lpEnumProc(Info, param);
341  }
342  }
343  }
344  else
345  {
346  // destory object
347  delete Info;
348  }
349  }
350  }
351 
352  szKeyName.ReleaseBuffer();
353  RegCloseKey(hKey);
354  }
355 
356  return TRUE;
357 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
BOOL IsSystem64Bit()
Definition: misc.cpp:339
#define DWORD
Definition: nt_native.h:44
static BOOLEAN bSuccess
Definition: drive.cpp:433
VOID FreeCachedEntries()
Definition: installed.cpp:359
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
#define L(x)
Definition: ntvdm.h:50
unsigned char * LPBYTE
Definition: typedefs.h:53
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3291
ATL::CAtlList< CInstalledApplicationInfo * > m_InfoList
Definition: installed.h:56
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4120
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:624
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
FxAutoRegKey hKey
ACCESS_MASK REGSAM
Definition: winreg.h:69
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3356
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2527
#define RegCloseKey(hKey)
Definition: registry.h:47
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CMainWindow::UpdateApplicationsList().

◆ FreeCachedEntries()

VOID CInstalledApps::FreeCachedEntries ( )

Definition at line 359 of file installed.cpp.

360 {
361  POSITION InfoListPosition = m_InfoList.GetHeadPosition();
362 
363  /* loop and deallocate all the cached app infos in the list */
364  while (InfoListPosition)
365  {
366  CInstalledApplicationInfo *Info = m_InfoList.GetNext(InfoListPosition);
367  delete Info;
368  }
369 
371 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:549
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
ATL::CAtlList< CInstalledApplicationInfo * > m_InfoList
Definition: installed.h:56
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:561
void RemoveAll()
Definition: atlcoll.h:725

Referenced by Enum(), and CMainWindow::ProcessWindowMessage().

Member Data Documentation

◆ m_InfoList

ATL::CAtlList<CInstalledApplicationInfo *> CInstalledApps::m_InfoList
private

Definition at line 56 of file installed.h.

Referenced by Enum(), and FreeCachedEntries().


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