ReactOS  0.4.15-dev-2103-g9dff498
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 174 of file installed.cpp.

175 {
177 
180 
181  int LoopTime;
182 
183  // test if the OS is 64 bit.
184  if (IsSystem64Bit())
185  {
186  // loop for all 3 combination.
187  // note that HKEY_CURRENT_USER\Software don't have a redirect
188  // https://docs.microsoft.com/en-us/windows/win32/winprog64/shared-registry-keys#redirected-shared-and-reflected-keys-under-wow64
189  LoopTime = 3;
190  }
191  else
192  {
193  // loop for 2 combination for KEY_WOW64_32KEY only
194  LoopTime = 2;
195  }
196 
197  // loop for all combination
198  for (int i = 0; i < LoopTime; i++)
199  {
201  HKEY hKey, hSubKey;
202  LONG ItemIndex = 0;
203  ATL::CStringW szKeyName;
204 
205  if (RegOpenKeyExW(RootKeyEnum[i],
206  L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
207  NULL,
208  KEY_READ | RegSamEnum[i],
209  &hKey) != ERROR_SUCCESS)
210  {
211  return FALSE;
212  }
213 
214  while (1)
215  {
216  dwSize = MAX_PATH;
217  if (RegEnumKeyExW(hKey, ItemIndex, szKeyName.GetBuffer(MAX_PATH), &dwSize, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
218  {
219  break;
220  }
221 
222  ItemIndex++;
223 
224  szKeyName.ReleaseBuffer();
225  if (RegOpenKeyW(hKey, szKeyName.GetString(), &hSubKey) == ERROR_SUCCESS)
226  {
227  BOOL bSuccess = FALSE;
228  CInstalledApplicationInfo *Info = new CInstalledApplicationInfo(RootKeyEnum[i] == HKEY_CURRENT_USER, RegSamEnum[i], hSubKey);
229  Info->szKeyName = szKeyName;
230 
231  // check for failure. if failed to init, Info->hSubKey will be set to NULL
232  if (Info->hSubKey)
233  {
234  // those items without display name are ignored
235  if (Info->GetApplicationRegString(L"DisplayName", Info->szDisplayName))
236  {
237  Info->GetApplicationRegString(L"DisplayIcon", Info->szDisplayIcon);
238  Info->GetApplicationRegString(L"DisplayVersion", Info->szDisplayVersion);
239  Info->GetApplicationRegString(L"Publisher", Info->szPublisher);
240  Info->GetApplicationRegString(L"RegOwner", Info->szRegOwner);
241  Info->GetApplicationRegString(L"ProductID", Info->szProductID);
242  Info->GetApplicationRegString(L"HelpLink", Info->szHelpLink);
243  Info->GetApplicationRegString(L"HelpTelephone", Info->szHelpTelephone);
244  Info->GetApplicationRegString(L"Readme", Info->szReadme);
245  Info->GetApplicationRegString(L"Contact", Info->szContact);
246  Info->GetApplicationRegString(L"URLUpdateInfo", Info->szURLUpdateInfo);
247  Info->GetApplicationRegString(L"URLInfoAbout", Info->szURLInfoAbout);
248  Info->GetApplicationRegString(L"Comments", Info->szComments);
249  if (Info->GetApplicationRegString(L"InstallDate", Info->szInstallDate) == FALSE)
250  {
251  // It might be a DWORD (Unix timestamp). try again.
252  DWORD dwInstallTimeStamp;
253  if (Info->GetApplicationRegDword(L"InstallDate", &dwInstallTimeStamp))
254  {
255  FILETIME InstallFileTime;
256  SYSTEMTIME InstallSystemTime, InstallLocalTime;
257 
258  UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime);
259  FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime);
260 
261  // convert to localtime
262  SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime, &InstallLocalTime);
263 
264  // convert to readable date string
265  int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT,
266  0,
267  &InstallLocalTime,
268  NULL, 0, 0);
269 
270  GetDateFormatW(LOCALE_USER_DEFAULT, // use default locale for current user
271  0,
272  &InstallLocalTime,
273  NULL, Info->szInstallDate.GetBuffer(cchTimeStrLen), cchTimeStrLen);
274  Info->szInstallDate.ReleaseBuffer();
275  }
276  }
277  Info->GetApplicationRegString(L"InstallLocation", Info->szInstallLocation);
278  Info->GetApplicationRegString(L"InstallSource", Info->szInstallSource);
279  Info->GetApplicationRegString(L"UninstallString", Info->szUninstallString);
280  Info->GetApplicationRegString(L"ModifyPath", Info->szModifyPath);
281 
282  bSuccess = TRUE;
283  }
284  }
285 
286  // close handle
287  if (Info->hSubKey)
288  {
289  CloseHandle(Info->hSubKey);
290  Info->hSubKey = NULL;
291  }
292 
293  if (bSuccess)
294  {
295  // add to InfoList.
297 
298  // invoke callback
299  if (lpEnumProc)
300  {
301  if ((EnumType == ENUM_ALL_INSTALLED) || /* All components */
302  ((EnumType == ENUM_INSTALLED_APPLICATIONS) && (!Info->bIsUpdate)) || /* Applications only */
303  ((EnumType == ENUM_UPDATES) && (Info->bIsUpdate))) /* Updates only */
304  {
305  lpEnumProc(Info, param);
306  }
307  }
308  }
309  else
310  {
311  // destory object
312  delete Info;
313  }
314  }
315  }
316 
317  szKeyName.ReleaseBuffer();
318  RegCloseKey(hKey);
319  }
320 
321 
322  return TRUE;
323 }
#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:461
static BOOLEAN bSuccess
Definition: drive.cpp:419
VOID FreeCachedEntries()
Definition: installed.cpp:325
_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:516
#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:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CMainWindow::UpdateApplicationsList().

◆ FreeCachedEntries()

VOID CInstalledApps::FreeCachedEntries ( )

Definition at line 325 of file installed.cpp.

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