ReactOS  0.4.15-dev-4853-g3a72a52
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
#define L(x)
Definition: ntvdm.h:50
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
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 
49  DWORD dwInstallTimeStamp;
50  SYSTEMTIME InstallLocalTime;
51  if (GetApplicationRegString(L"InstallDate", szInstallDate))
52  {
53  ZeroMemory(&InstallLocalTime, sizeof(InstallLocalTime));
54  // Check if we have 8 characters to parse the datetime.
55  // Maybe other formats exist as well?
57  if (szInstallDate.GetLength() == 8)
58  {
59  InstallLocalTime.wYear = wcstol(szInstallDate.Left(4).GetString(), NULL, 10);
60  InstallLocalTime.wMonth = wcstol(szInstallDate.Mid(4, 2).GetString(), NULL, 10);
61  InstallLocalTime.wDay = wcstol(szInstallDate.Mid(6, 2).GetString(), NULL, 10);
62  }
63  }
64  // It might be a DWORD (Unix timestamp). try again.
65  else if (GetApplicationRegDword(L"InstallDate", &dwInstallTimeStamp))
66  {
67  FILETIME InstallFileTime;
68  SYSTEMTIME InstallSystemTime;
69 
70  UnixTimeToFileTime(dwInstallTimeStamp, &InstallFileTime);
71  FileTimeToSystemTime(&InstallFileTime, &InstallSystemTime);
72 
73  // convert to localtime
74  SystemTimeToTzSpecificLocalTime(NULL, &InstallSystemTime, &InstallLocalTime);
75  }
76 
77  // convert to readable date string
78  int cchTimeStrLen = GetDateFormatW(LOCALE_USER_DEFAULT, 0, &InstallLocalTime, NULL, 0, 0);
79 
81  LOCALE_USER_DEFAULT, // use default locale for current user
82  0, &InstallLocalTime, NULL, szInstallDate.GetBuffer(cchTimeStrLen), cchTimeStrLen);
84 
85  GetApplicationRegString(L"InstallLocation", szInstallLocation);
86  GetApplicationRegString(L"InstallSource", szInstallSource);
87  DWORD dwWindowsInstaller = 0;
88  if (GetApplicationRegDword(L"WindowsInstaller", &dwWindowsInstaller) && dwWindowsInstaller)
89  {
90  // MSI has the same info in Uninstall / modify, so manually build it
92  }
93  else
94  {
95  GetApplicationRegString(L"UninstallString", szUninstallString);
96  }
97  DWORD dwNoModify = 0;
98  if (!GetApplicationRegDword(L"NoModify", &dwNoModify))
99  {
100  CStringW Tmp;
101  if (GetApplicationRegString(L"NoModify", Tmp))
102  {
103  dwNoModify = Tmp.GetLength() > 0 ? (Tmp[0] == '1') : 0;
104  }
105  else
106  {
107  dwNoModify = 0;
108  }
109  }
110  if (!dwNoModify)
111  {
112  if (dwWindowsInstaller)
113  {
114  szModifyPath.Format(L"msiexec /i%s", m_szKeyName.GetString());
115  }
116  else
117  {
118  GetApplicationRegString(L"ModifyPath", szModifyPath);
119  }
120  }
121 
123  m_hSubKey = NULL;
124  }
125 }
int GetLength() const
Definition: atlsimpstr.h:356
#define CloseHandle
Definition: compat.h:598
WORD wMonth
Definition: winbase.h:903
#define LOCALE_USER_DEFAULT
CStringT Mid(int iFirst, int nCount) const
Definition: cstringt.h:700
#define ZeroMemory
Definition: winbase.h:1667
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:753
_Check_return_ long __cdecl wcstol(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
BOOL WINAPI SystemTimeToTzSpecificLocalTime(CONST TIME_ZONE_INFORMATION *lpTimeZoneInformation, CONST SYSTEMTIME *lpUniversalTime, LPSYSTEMTIME lpLocalTime)
Definition: timezone.c:377
WORD wYear
Definition: winbase.h:902
#define L(x)
Definition: ntvdm.h:50
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
PCXSTR GetString() const
Definition: atlsimpstr.h:361
unsigned long DWORD
Definition: ntddk_ex.h:95
INT WINAPI GetDateFormatW(LCID lcid, DWORD dwFlags, const SYSTEMTIME *lpTime, LPCWSTR lpFormat, LPWSTR lpDateStr, INT cchOut)
Definition: lcformat.c:979
WORD wDay
Definition: winbase.h:905
BOOL GetApplicationRegString(LPCWSTR lpKeyName, ATL::CStringW &String)
Definition: installed.cpp:127
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
Definition: misc.cpp:394
#define NULL
Definition: types.h:112
BOOL GetApplicationRegDword(LPCWSTR lpKeyName, DWORD *lpValue)
Definition: installed.cpp:183
CStringT & Trim()
Definition: cstringt.h:971
CStringT Left(int nCount) const
Definition: cstringt.h:728

◆ GetApplicationRegDword()

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

Definition at line 183 of file installed.cpp.

184 {
185  DWORD dwSize = sizeof(DWORD), dwType;
187  lpKeyName,
188  NULL,
189  &dwType,
190  (LPBYTE)lpValue,
191  &dwSize) != ERROR_SUCCESS || dwType != REG_DWORD)
192  {
193  return FALSE;
194  }
195 
196  return TRUE;
197 }
#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 127 of file installed.cpp.

128 {
129  DWORD dwAllocated = 0, dwSize, dwType;
130 
131  // retrieve the size of value first.
132  if (RegQueryValueExW(m_hSubKey, lpKeyName, NULL, &dwType, NULL, &dwAllocated) != ERROR_SUCCESS)
133  {
134  String.Empty();
135  return FALSE;
136  }
137 
138  if (dwType != REG_SZ && dwType != REG_EXPAND_SZ)
139  {
140  String.Empty();
141  return FALSE;
142  }
143 
144  // query the value
145  dwSize = dwAllocated;
146  LSTATUS Result =
147  RegQueryValueExW(m_hSubKey, lpKeyName, NULL, NULL, (LPBYTE)String.GetBuffer(dwAllocated / sizeof(WCHAR)), &dwSize);
148 
149  dwSize = min(dwAllocated, dwSize);
150  // CString takes care of zero-terminating it
151  String.ReleaseBuffer(dwSize / sizeof(WCHAR));
152 
153  if (Result != ERROR_SUCCESS)
154  {
155  String.Empty();
156  return FALSE;
157  }
158 
159  if (dwType == REG_EXPAND_SZ)
160  {
161  CStringW Tmp;
162 
164  if (dwLen > 0)
165  {
166  BOOL bSuccess = ExpandEnvironmentStringsW(String, Tmp.GetBuffer(dwLen), dwLen) == dwLen;
167  Tmp.ReleaseBuffer(dwLen - 1);
168  if (bSuccess)
169  {
170  String = Tmp;
171  }
172  else
173  {
174  String.Empty();
175  return FALSE;
176  }
177  }
178  }
179 
180  return TRUE;
181 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
static BOOLEAN bSuccess
Definition: drive.cpp:430
unsigned char * LPBYTE
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2430
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
_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 REG_EXPAND_SZ
Definition: nt_native.h:1494
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
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 219 of file installed.cpp.

220 {
221  ATL::CStringW szFullName = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + m_szKeyName;
222  HMODULE hMod = GetModuleHandleW(L"advapi32.dll");
223  RegDeleteKeyExWProc pRegDeleteKeyExW;
224 
225  // TODO: if there are subkeys inside, simply RegDeleteKeyExW
226  // (or RegDeleteKeyW on Server 2003 SP0 and earlier) will fail
227  // we don't have RegDeleteTree for ReactOS now. (It's a WinVista API)
228  // write a function to delete all subkeys recursively to solve this
229  // or consider letting ReactOS having this API
230 
231  /* Load RegDeleteKeyExW from advapi32.dll if available */
232  if (hMod)
233  {
234  pRegDeleteKeyExW = (RegDeleteKeyExWProc)GetProcAddress(hMod, "RegDeleteKeyExW");
235 
236  if (pRegDeleteKeyExW)
237  {
238  /* Return it */
239  return pRegDeleteKeyExW(m_IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, szFullName, m_WowKey, 0);
240  }
241  }
242 
243  /* Otherwise, return non-Ex function */
245 }
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
#define L(x)
Definition: ntvdm.h:50
LSTATUS(WINAPI * RegDeleteKeyExWProc)(HKEY, LPCWSTR, REGSAM, DWORD)
Definition: installed.cpp:217
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 199 of file installed.cpp.

200 {
201  if (szDisplayIcon.IsEmpty())
202  {
203  return FALSE;
204  }
206  return TRUE;
207 }
#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 209 of file installed.cpp.

210 {
211  if (!bModify)
212  WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_REMOVE, szDisplayName);
213 
214  return StartProcess(bModify ? szModifyPath : szUninstallString, TRUE);
215 }
#define TRUE
Definition: types.h:120
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2880
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:226
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 EnsureDetailsLoaded(), and 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: