ReactOS  0.4.15-dev-2721-g5912c11
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 47 of file installed.h.

Member Function Documentation

◆ Enum()

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

Definition at line 177 of file installed.cpp.

178 {
180 
183 
184  int LoopTime;
185 
186  // test if the OS is 64 bit.
187  if (IsSystem64Bit())
188  {
189  // loop for all 3 combination.
190  // note that HKEY_CURRENT_USER\Software don't have a redirect
191  // https://docs.microsoft.com/en-us/windows/win32/winprog64/shared-registry-keys#redirected-shared-and-reflected-keys-under-wow64
192  LoopTime = 3;
193  }
194  else
195  {
196  // loop for 2 combination for KEY_WOW64_32KEY only
197  LoopTime = 2;
198  }
199 
200  // loop for all combination
201  for (int i = 0; i < LoopTime; i++)
202  {
204  HKEY hKey, hSubKey;
205  LONG ItemIndex = 0;
206  ATL::CStringW szKeyName;
207 
208  if (RegOpenKeyExW(RootKeyEnum[i],
209  L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
210  NULL,
211  KEY_READ | RegSamEnum[i],
212  &hKey) != ERROR_SUCCESS)
213  {
214  return FALSE;
215  }
216 
217  while (1)
218  {
219  dwSize = MAX_PATH;
220  if (RegEnumKeyExW(hKey, ItemIndex, szKeyName.GetBuffer(MAX_PATH), &dwSize, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
221  {
222  break;
223  }
224 
225  ItemIndex++;
226 
227  szKeyName.ReleaseBuffer();
228  if (RegOpenKeyW(hKey, szKeyName.GetString(), &hSubKey) == ERROR_SUCCESS)
229  {
230  BOOL bSuccess = FALSE;
231  CInstalledApplicationInfo *Info = new CInstalledApplicationInfo(RootKeyEnum[i] == HKEY_CURRENT_USER, RegSamEnum[i], hSubKey);
232  Info->szKeyName = szKeyName;
233 
234  // check for failure. if failed to init, Info->hSubKey will be set to NULL
235  if (Info->hSubKey)
236  {
237  // those items without display name are ignored
238  if (Info->GetApplicationRegString(L"DisplayName", Info->szDisplayName))
239  {
240  Info->GetApplicationRegString(L"DisplayIcon", Info->szDisplayIcon);
241  Info->GetApplicationRegString(L"DisplayVersion", Info->szDisplayVersion);
242  Info->GetApplicationRegString(L"Publisher", Info->szPublisher);
243  Info->GetApplicationRegString(L"RegOwner", Info->szRegOwner);
244  Info->GetApplicationRegString(L"ProductID", Info->szProductID);
245  Info->GetApplicationRegString(L"HelpLink", Info->szHelpLink);
246  Info->GetApplicationRegString(L"HelpTelephone", Info->szHelpTelephone);
247  Info->GetApplicationRegString(L"Readme", Info->szReadme);
248  Info->GetApplicationRegString(L"Contact", Info->szContact);
249  Info->GetApplicationRegString(L"URLUpdateInfo", Info->szURLUpdateInfo);
250  Info->GetApplicationRegString(L"URLInfoAbout", Info->szURLInfoAbout);
251  Info->GetApplicationRegString(L"Comments", Info->szComments);
252  if (Info->GetApplicationRegString(L"InstallDate", Info->szInstallDate) == FALSE)
253  {
254  // It might be a DWORD (Unix timestamp). try again.
255  DWORD dwInstallTimeStamp;
256  if (Info->GetApplicationRegDword(L"InstallDate", &dwInstallTimeStamp))
257  {
258  FILETIME InstallFileTime;
259  SYSTEMTIME InstallSystemTime, InstallLocalTime;
260 
261  UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime);
262  FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime);
263 
264  // convert to localtime
265  SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime, &InstallLocalTime);
266 
267  // convert to readable date string
268  int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT,
269  0,
270  &InstallLocalTime,
271  NULL, 0, 0);
272 
273  GetDateFormatW(LOCALE_USER_DEFAULT, // use default locale for current user
274  0,
275  &InstallLocalTime,
276  NULL, Info->szInstallDate.GetBuffer(cchTimeStrLen), cchTimeStrLen);
277  Info->szInstallDate.ReleaseBuffer();
278  }
279  }
280  Info->GetApplicationRegString(L"InstallLocation", Info->szInstallLocation);
281  Info->GetApplicationRegString(L"InstallSource", Info->szInstallSource);
282  Info->GetApplicationRegString(L"UninstallString", Info->szUninstallString);
283  Info->GetApplicationRegString(L"ModifyPath", Info->szModifyPath);
284 
285  bSuccess = TRUE;
286  }
287  }
288 
289  // close handle
290  if (Info->hSubKey)
291  {
292  CloseHandle(Info->hSubKey);
293  Info->hSubKey = NULL;
294  }
295 
296  if (bSuccess)
297  {
298  // add to InfoList.
300 
301  // invoke callback
302  if (lpEnumProc)
303  {
304  if ((EnumType == ENUM_ALL_INSTALLED) || /* All components */
305  ((EnumType == ENUM_INSTALLED_APPLICATIONS) && (!Info->bIsUpdate)) || /* Applications only */
306  ((EnumType == ENUM_UPDATES) && (Info->bIsUpdate))) /* Updates only */
307  {
308  lpEnumProc(Info, param);
309  }
310  }
311  }
312  else
313  {
314  // destory object
315  delete Info;
316  }
317  }
318  }
319 
320  szKeyName.ReleaseBuffer();
321  RegCloseKey(hKey);
322  }
323 
324 
325  return TRUE;
326 }
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define LOCALE_USER_DEFAULT
#define HKEY_CURRENT_USER
Definition: winreg.h:11
BOOL IsSystem64Bit()
Definition: misc.cpp:481
static BOOLEAN bSuccess
Definition: drive.cpp:432
VOID FreeCachedEntries()
Definition: installed.cpp:328
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
BOOL WINAPI SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime)
Definition: timezone.c:377
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
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:3296
ATL::CAtlList< CInstalledApplicationInfo * > m_InfoList
Definition: installed.h:49
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:34
PCXSTR GetString() const
Definition: atlsimpstr.h:361
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
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
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
Definition: misc.cpp:536
#define NULL
Definition: types.h:112
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#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
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 328 of file installed.cpp.

329 {
330  POSITION InfoListPosition = m_InfoList.GetHeadPosition();
331 
332  /* loop and deallocate all the cached app infos in the list */
333  while (InfoListPosition)
334  {
335  CInstalledApplicationInfo *Info = m_InfoList.GetNext(InfoListPosition);
336  delete Info;
337  }
338 
340 }
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:49
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 49 of file installed.h.

Referenced by Enum(), and FreeCachedEntries().


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