ReactOS  0.4.15-dev-3728-ga92304f
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 176 of file installed.cpp.

177 {
179 
182 
183  int LoopTime;
184 
185  // test if the OS is 64 bit.
186  if (IsSystem64Bit())
187  {
188  // loop for all 3 combination.
189  // note that HKEY_CURRENT_USER\Software don't have a redirect
190  // https://docs.microsoft.com/en-us/windows/win32/winprog64/shared-registry-keys#redirected-shared-and-reflected-keys-under-wow64
191  LoopTime = 3;
192  }
193  else
194  {
195  // loop for 2 combination for KEY_WOW64_32KEY only
196  LoopTime = 2;
197  }
198 
199  // loop for all combination
200  for (int i = 0; i < LoopTime; i++)
201  {
203  HKEY hKey, hSubKey;
204  LONG ItemIndex = 0;
205  ATL::CStringW szKeyName;
206 
207  if (RegOpenKeyExW(RootKeyEnum[i],
208  L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
209  NULL,
210  KEY_READ | RegSamEnum[i],
211  &hKey) != ERROR_SUCCESS)
212  {
213  return FALSE;
214  }
215 
216  while (1)
217  {
218  dwSize = MAX_PATH;
219  if (RegEnumKeyExW(hKey, ItemIndex, szKeyName.GetBuffer(MAX_PATH), &dwSize, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
220  {
221  break;
222  }
223 
224  ItemIndex++;
225 
226  szKeyName.ReleaseBuffer();
227  if (RegOpenKeyW(hKey, szKeyName, &hSubKey) == ERROR_SUCCESS)
228  {
229  DWORD dwValue = 0;
230  BOOL bIsSystemComponent = FALSE;
231 
232  dwSize = sizeof(DWORD);
233  if (RegQueryValueExW(hSubKey, L"SystemComponent", NULL, NULL, (LPBYTE)&dwValue, &dwSize) == ERROR_SUCCESS)
234  {
235  bIsSystemComponent = (dwValue == 0x1);
236  }
237  // Ignore system components
238  if (bIsSystemComponent)
239  {
240  RegCloseKey(hSubKey);
241  continue;
242  }
243 
244  BOOL bSuccess = FALSE;
245  CInstalledApplicationInfo *Info = new CInstalledApplicationInfo(RootKeyEnum[i] == HKEY_CURRENT_USER, RegSamEnum[i], hSubKey, szKeyName);
246 
247  // items without display name are ignored
248  if (Info->GetApplicationRegString(L"DisplayName", Info->szDisplayName))
249  {
250  Info->GetApplicationRegString(L"DisplayIcon", Info->szDisplayIcon);
251  Info->GetApplicationRegString(L"DisplayVersion", Info->szDisplayVersion);
252  Info->GetApplicationRegString(L"Comments", Info->szComments);
253 
254  bSuccess = TRUE;
255  }
256 
257  if (bSuccess)
258  {
259  // add to InfoList.
261 
262  // invoke callback
263  if (lpEnumProc)
264  {
265  if ((EnumType == ENUM_ALL_INSTALLED) || /* All components */
266  ((EnumType == ENUM_INSTALLED_APPLICATIONS) && (!Info->bIsUpdate)) || /* Applications only */
267  ((EnumType == ENUM_UPDATES) && (Info->bIsUpdate))) /* Updates only */
268  {
269  lpEnumProc(Info, param);
270  }
271  }
272  }
273  else
274  {
275  // destory object
276  delete Info;
277  }
278  }
279  }
280 
281  szKeyName.ReleaseBuffer();
282  RegCloseKey(hKey);
283  }
284 
285  return TRUE;
286 }
#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:432
VOID FreeCachedEntries()
Definition: installed.cpp:288
_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:40
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 288 of file installed.cpp.

289 {
290  POSITION InfoListPosition = m_InfoList.GetHeadPosition();
291 
292  /* loop and deallocate all the cached app infos in the list */
293  while (InfoListPosition)
294  {
295  CInstalledApplicationInfo *Info = m_InfoList.GetNext(InfoListPosition);
296  delete Info;
297  }
298 
300 }
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: