ReactOS  0.4.15-dev-3324-gda4e15f
CInstalledApplicationInfo Class Reference

#include <installed.h>

Collaboration diagram for CInstalledApplicationInfo:

Public Member Functions

 CInstalledApplicationInfo (BOOL bIsUserKey, REGSAM RegWowKey, HKEY hKey, const CStringW &szKeyName)
 
 ~CInstalledApplicationInfo ()
 
VOID EnsureDetailsLoaded ()
 
BOOL GetApplicationRegString (LPCWSTR lpKeyName, ATL::CStringW &String)
 
BOOL GetApplicationRegDword (LPCWSTR lpKeyName, DWORD *lpValue)
 
BOOL RetrieveIcon (ATL::CStringW &IconLocation)
 
BOOL UninstallApplication (BOOL bModify)
 
LSTATUS RemoveFromRegistry ()
 

Public Attributes

BOOL bIsUpdate
 
CStringW szDisplayIcon
 
CStringW szDisplayName
 
CStringW szDisplayVersion
 
CStringW szComments
 
CStringW szPublisher
 
CStringW szRegOwner
 
CStringW szProductID
 
CStringW szHelpLink
 
CStringW szHelpTelephone
 
CStringW szReadme
 
CStringW szContact
 
CStringW szURLUpdateInfo
 
CStringW szURLInfoAbout
 
CStringW szInstallDate
 
CStringW szInstallLocation
 
CStringW szInstallSource
 
CStringW szUninstallString
 
CStringW szModifyPath
 

Private Attributes

BOOL m_IsUserKey
 
REGSAM m_WowKey
 
HKEY m_hSubKey
 
CStringW m_szKeyName
 

Detailed Description

Definition at line 6 of file installed.h.

Constructor & Destructor Documentation

◆ CInstalledApplicationInfo()

CInstalledApplicationInfo::CInstalledApplicationInfo ( BOOL  bIsUserKey,
REGSAM  RegWowKey,
HKEY  hKey,
const CStringW szKeyName 
)

Definition at line 15 of file installed.cpp.

16  : m_IsUserKey(bIsUserKey)
17  , m_WowKey(RegWowKey)
18  , m_hSubKey(hKey)
19  , m_szKeyName(szKeyName)
20 {
21  DWORD dwSize = 0;
22  bIsUpdate = (RegQueryValueExW(m_hSubKey, L"ParentKeyName", NULL, NULL, NULL, &dwSize) == ERROR_SUCCESS);
23 }
#define ERROR_SUCCESS
Definition: deptool.c:10
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
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

◆ ~CInstalledApplicationInfo()

CInstalledApplicationInfo::~CInstalledApplicationInfo ( )

Definition at line 25 of file installed.cpp.

26 {
27  if (m_hSubKey)
28  {
30  m_hSubKey = NULL;
31  }
32 }
#define CloseHandle
Definition: compat.h:598
#define NULL
Definition: types.h:112

Member Function Documentation

◆ EnsureDetailsLoaded()

void CInstalledApplicationInfo::EnsureDetailsLoaded ( )

Definition at line 34 of file installed.cpp.

35 {
36  // Key not closed, so we have not loaded details yet
37  if (m_hSubKey)
38  {
43  GetApplicationRegString(L"HelpTelephone", szHelpTelephone);
46  GetApplicationRegString(L"URLUpdateInfo", szURLUpdateInfo);
48  if (GetApplicationRegString(L"InstallDate", szInstallDate) == FALSE)
49  {
50  // It might be a DWORD (Unix timestamp). try again.
51  DWORD dwInstallTimeStamp;
52  if (GetApplicationRegDword(L"InstallDate", &dwInstallTimeStamp))
53  {
54  FILETIME InstallFileTime;
55  SYSTEMTIME InstallSystemTime, InstallLocalTime;
56 
57  UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime);
58  FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime);
59 
60  // convert to localtime
61  SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime, &InstallLocalTime);
62 
63  // convert to readable date string
64  int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &InstallLocalTime, NULL, 0, 0);
65 
67  LOCALE_USER_DEFAULT, // use default locale for current user
68  0, &InstallLocalTime, NULL, szInstallDate.GetBuffer(cchTimeStrLen), cchTimeStrLen);
70  }
71  }
72  GetApplicationRegString(L"InstallLocation", szInstallLocation);
73  GetApplicationRegString(L"InstallSource", szInstallSource);
74  GetApplicationRegString(L"UninstallString", szUninstallString);
76 
78  m_hSubKey = NULL;
79  }
80 }
#define CloseHandle
Definition: compat.h:598
#define LOCALE_USER_DEFAULT
BOOL WINAPI SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime)
Definition: timezone.c:377
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
#define FALSE
Definition: types.h:117
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
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
BOOL GetApplicationRegString(LPCWSTR lpKeyName, ATL::CStringW &String)
Definition: installed.cpp:82
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
Definition: misc.cpp:396
#define NULL
Definition: types.h:112
BOOL GetApplicationRegDword(LPCWSTR lpKeyName, DWORD *lpValue)
Definition: installed.cpp:112

◆ GetApplicationRegDword()

BOOL CInstalledApplicationInfo::GetApplicationRegDword ( LPCWSTR  lpKeyName,
DWORD lpValue 
)

Definition at line 112 of file installed.cpp.

113 {
114  DWORD dwSize = sizeof(DWORD), dwType;
116  lpKeyName,
117  NULL,
118  &dwType,
119  (LPBYTE)lpValue,
120  &dwSize) != ERROR_SUCCESS || dwType != REG_DWORD)
121  {
122  return FALSE;
123  }
124 
125  return TRUE;
126 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define DWORD
Definition: nt_native.h:44
unsigned char * LPBYTE
Definition: typedefs.h:53
#define FALSE
Definition: types.h:117
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
unsigned long DWORD
Definition: ntddk_ex.h:95
#define NULL
Definition: types.h:112
#define REG_DWORD
Definition: sdbapi.c:596
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by EnsureDetailsLoaded().

◆ GetApplicationRegString()

BOOL CInstalledApplicationInfo::GetApplicationRegString ( LPCWSTR  lpKeyName,
ATL::CStringW String 
)

Definition at line 82 of file installed.cpp.

83 {
84  DWORD dwAllocated = 0, dwSize, dwType;
85 
86  // retrieve the size of value first.
87  if (RegQueryValueExW(m_hSubKey, lpKeyName, NULL, &dwType, NULL, &dwAllocated) != ERROR_SUCCESS ||
88  dwType != REG_SZ)
89  {
90  String.Empty();
91  return FALSE;
92  }
93 
94  // query the value
95  dwSize = dwAllocated;
96  LSTATUS Result =
97  RegQueryValueExW(m_hSubKey, lpKeyName, NULL, NULL, (LPBYTE)String.GetBuffer(dwAllocated / sizeof(WCHAR)), &dwSize);
98 
99  dwSize = min(dwAllocated, dwSize);
100  // CString takes care of zero-terminating it
101  String.ReleaseBuffer(dwSize / sizeof(WCHAR));
102 
103  if (Result != ERROR_SUCCESS)
104  {
105  String.Empty();
106  return FALSE;
107  }
108 
109  return TRUE;
110 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
unsigned char * LPBYTE
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
#define FALSE
Definition: types.h:117
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define REG_SZ
Definition: layer.c:22

Referenced by EnsureDetailsLoaded().

◆ RemoveFromRegistry()

LSTATUS CInstalledApplicationInfo::RemoveFromRegistry ( )

Definition at line 148 of file installed.cpp.

149 {
150  ATL::CStringW szFullName = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + m_szKeyName;
151  HMODULE hMod = GetModuleHandleW(L"advapi32.dll");
152  RegDeleteKeyExWProc pRegDeleteKeyExW;
153 
154  // TODO: if there are subkeys inside, simply RegDeleteKeyExW
155  // (or RegDeleteKeyW on Server 2003 SP0 and earlier) will fail
156  // we don't have RegDeleteTree for ReactOS now. (It's a WinVista API)
157  // write a function to delete all subkeys recursively to solve this
158  // or consider letting ReactOS having this API
159 
160  /* Load RegDeleteKeyExW from advapi32.dll if available */
161  if (hMod)
162  {
163  pRegDeleteKeyExW = (RegDeleteKeyExWProc)GetProcAddress(hMod, "RegDeleteKeyExW");
164 
165  if (pRegDeleteKeyExW)
166  {
167  /* Return it */
168  return pRegDeleteKeyExW(m_IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, szFullName, m_WowKey, 0);
169  }
170  }
171 
172  /* Otherwise, return non-Ex function */
174 }
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
LSTATUS(WINAPI * RegDeleteKeyExWProc)(HKEY, LPCWSTR, REGSAM, DWORD)
Definition: installed.cpp:146
static const WCHAR L[]
Definition: oid.c:1250
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define GetProcAddress(x, y)
Definition: compat.h:612
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CMainWindow::RemoveSelectedAppFromRegistry().

◆ RetrieveIcon()

BOOL CInstalledApplicationInfo::RetrieveIcon ( ATL::CStringW IconLocation)

Definition at line 128 of file installed.cpp.

129 {
130  if (szDisplayIcon.IsEmpty())
131  {
132  return FALSE;
133  }
135  return TRUE;
136 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
bool IsEmpty() const
Definition: atlsimpstr.h:379

Referenced by CAppsListView::AddInstalledApplication().

◆ UninstallApplication()

BOOL CInstalledApplicationInfo::UninstallApplication ( BOOL  bModify)

Definition at line 138 of file installed.cpp.

139 {
140  if (!bModify)
141  WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_REMOVE, szDisplayName);
142 
143  return StartProcess(bModify ? szModifyPath : szUninstallString, TRUE);
144 }
#define TRUE
Definition: types.h:120
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2753
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:228
BOOL StartProcess(const ATL::CStringW &Path, BOOL Wait)
Definition: misc.cpp:83

Referenced by CMainWindow::UninstallSelectedApp().

Member Data Documentation

◆ bIsUpdate

BOOL CInstalledApplicationInfo::bIsUpdate

Definition at line 28 of file installed.h.

Referenced by CInstalledApplicationInfo().

◆ m_hSubKey

HKEY CInstalledApplicationInfo::m_hSubKey
private

◆ m_IsUserKey

BOOL CInstalledApplicationInfo::m_IsUserKey
private

Definition at line 9 of file installed.h.

Referenced by RemoveFromRegistry().

◆ m_szKeyName

CStringW CInstalledApplicationInfo::m_szKeyName
private

Definition at line 13 of file installed.h.

Referenced by RemoveFromRegistry().

◆ m_WowKey

REGSAM CInstalledApplicationInfo::m_WowKey
private

Definition at line 10 of file installed.h.

Referenced by RemoveFromRegistry().

◆ szComments

CStringW CInstalledApplicationInfo::szComments

Definition at line 32 of file installed.h.

Referenced by CAppsListView::AddInstalledApplication().

◆ szContact

CStringW CInstalledApplicationInfo::szContact

Definition at line 41 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szDisplayIcon

CStringW CInstalledApplicationInfo::szDisplayIcon

Definition at line 29 of file installed.h.

Referenced by RetrieveIcon().

◆ szDisplayName

CStringW CInstalledApplicationInfo::szDisplayName

Definition at line 30 of file installed.h.

Referenced by CAppsListView::AddInstalledApplication(), and UninstallApplication().

◆ szDisplayVersion

CStringW CInstalledApplicationInfo::szDisplayVersion

Definition at line 31 of file installed.h.

Referenced by CAppsListView::AddInstalledApplication().

◆ szHelpLink

CStringW CInstalledApplicationInfo::szHelpLink

Definition at line 38 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szHelpTelephone

CStringW CInstalledApplicationInfo::szHelpTelephone

Definition at line 39 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szInstallDate

CStringW CInstalledApplicationInfo::szInstallDate

Definition at line 44 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szInstallLocation

CStringW CInstalledApplicationInfo::szInstallLocation

Definition at line 45 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szInstallSource

CStringW CInstalledApplicationInfo::szInstallSource

Definition at line 46 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szModifyPath

CStringW CInstalledApplicationInfo::szModifyPath

Definition at line 48 of file installed.h.

Referenced by EnsureDetailsLoaded(), and UninstallApplication().

◆ szProductID

CStringW CInstalledApplicationInfo::szProductID

Definition at line 37 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szPublisher

CStringW CInstalledApplicationInfo::szPublisher

Definition at line 35 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szReadme

CStringW CInstalledApplicationInfo::szReadme

Definition at line 40 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szRegOwner

CStringW CInstalledApplicationInfo::szRegOwner

Definition at line 36 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szUninstallString

CStringW CInstalledApplicationInfo::szUninstallString

Definition at line 47 of file installed.h.

Referenced by EnsureDetailsLoaded(), and UninstallApplication().

◆ szURLInfoAbout

CStringW CInstalledApplicationInfo::szURLInfoAbout

Definition at line 43 of file installed.h.

Referenced by EnsureDetailsLoaded().

◆ szURLUpdateInfo

CStringW CInstalledApplicationInfo::szURLUpdateInfo

Definition at line 42 of file installed.h.

Referenced by EnsureDetailsLoaded().


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