ReactOS  0.4.15-dev-2534-geba00d1
CInstalledApplicationInfo Class Reference

#include <installed.h>

Collaboration diagram for CInstalledApplicationInfo:

Public Member Functions

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

Public Attributes

BOOL IsUserKey
 
REGSAM WowKey
 
HKEY hSubKey
 
BOOL bIsUpdate = FALSE
 
ATL::CStringW szKeyName
 
ATL::CStringW szDisplayIcon
 
ATL::CStringW szDisplayName
 
ATL::CStringW szDisplayVersion
 
ATL::CStringW szPublisher
 
ATL::CStringW szRegOwner
 
ATL::CStringW szProductID
 
ATL::CStringW szHelpLink
 
ATL::CStringW szHelpTelephone
 
ATL::CStringW szReadme
 
ATL::CStringW szContact
 
ATL::CStringW szURLUpdateInfo
 
ATL::CStringW szURLInfoAbout
 
ATL::CStringW szComments
 
ATL::CStringW szInstallDate
 
ATL::CStringW szInstallLocation
 
ATL::CStringW szInstallSource
 
ATL::CStringW szUninstallString
 
ATL::CStringW szModifyPath
 

Detailed Description

Definition at line 6 of file installed.h.

Constructor & Destructor Documentation

◆ CInstalledApplicationInfo()

CInstalledApplicationInfo::CInstalledApplicationInfo ( BOOL  bIsUserKey,
REGSAM  RegWowKey,
HKEY  hKey 
)

Definition at line 15 of file installed.cpp.

16  : IsUserKey(bIsUserKey), WowKey(RegWowKey), hSubKey(hKey)
17 {
18  // if Initialize failed, hSubKey will be closed automatically and set to zero
19 
20  DWORD dwSize = MAX_PATH, dwType, dwValue;
21  BOOL bIsSystemComponent;
22  ATL::CStringW szParentKeyName;
23 
24  dwType = REG_DWORD;
25  dwSize = sizeof(DWORD);
26 
28  L"SystemComponent",
29  NULL,
30  &dwType,
31  (LPBYTE)&dwValue,
32  &dwSize) == ERROR_SUCCESS)
33  {
34  bIsSystemComponent = (dwValue == 0x1);
35  }
36  else
37  {
38  bIsSystemComponent = FALSE;
39  }
40 
41  dwType = REG_SZ;
42  dwSize = MAX_PATH * sizeof(WCHAR);
44  L"ParentKeyName",
45  NULL,
46  &dwType,
47  (LPBYTE)szParentKeyName.GetBuffer(MAX_PATH),
48  &dwSize) == ERROR_SUCCESS);
49  szParentKeyName.ReleaseBuffer();
50 
51  if (bIsSystemComponent)
52  {
54  hSubKey = NULL;
55  }
56 
57 }
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD
Definition: nt_native.h:44
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 WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define REG_DWORD
Definition: sdbapi.c:596
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define REG_SZ
Definition: layer.c:22

◆ ~CInstalledApplicationInfo()

CInstalledApplicationInfo::~CInstalledApplicationInfo ( )

Definition at line 59 of file installed.cpp.

60 {
61  if (hSubKey)
62  {
64  hSubKey = NULL;
65  }
66 }
#define CloseHandle
Definition: compat.h:598
#define NULL
Definition: types.h:112

Member Function Documentation

◆ GetApplicationRegDword()

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

Definition at line 112 of file installed.cpp.

113 {
114  DWORD dwType = REG_DWORD;
115  DWORD dwSize = sizeof(DWORD);
117  lpKeyName,
118  NULL,
119  &dwType,
120  (LPBYTE)lpValue,
121  &dwSize) != ERROR_SUCCESS)
122  {
123  return FALSE;
124  }
125 
126  return TRUE;
127 }
#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:4116
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

◆ GetApplicationRegString()

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

Definition at line 68 of file installed.cpp.

69 {
70  DWORD dwSize = 0;
71  String.Empty();
72  DWORD dwType;
73 
74  // retrieve the size of value first.
76  lpKeyName,
77  NULL,
78  &dwType,
79  NULL,
80  &dwSize) != ERROR_SUCCESS)
81  {
82  return FALSE;
83  }
84 
85  // TODO: I assume the type as REG_SZ. but I think REG_EXPAND_SZ should be handled correctly too.
86  if (dwType != REG_SZ)
87  {
88  return FALSE;
89  }
90 
91  // allocate buffer.
92  // attention: dwSize is size in bytes, and RegQueryValueExW does not guarantee the terminating null character.
93  String.GetBuffer(dwSize + sizeof(WCHAR));
94 
95  // query the value
97  lpKeyName,
98  NULL,
99  NULL,
100  (LPBYTE)String.GetBuffer(),
101  &dwSize) != ERROR_SUCCESS)
102  {
103  String.ReleaseBuffer();
104  String.Empty();
105  return FALSE;
106  }
107  String.GetBuffer()[dwSize / sizeof(WCHAR)] = L'\0'; // ensure zero terminated
108  String.ReleaseBuffer();
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
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define REG_SZ
Definition: layer.c:22

◆ RemoveFromRegistry()

LSTATUS CInstalledApplicationInfo::RemoveFromRegistry ( )

Definition at line 149 of file installed.cpp.

150 {
151  ATL::CStringW szFullName = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + szKeyName;
152  HMODULE hMod = GetModuleHandleW(L"advapi32.dll");
153  RegDeleteKeyExWProc pRegDeleteKeyExW;
154 
155  // TODO: if there are subkeys inside, simply RegDeleteKeyExW
156  // (or RegDeleteKeyW on Server 2003 SP0 and earlier) will fail
157  // we don't have RegDeleteTree for ReactOS now. (It's a WinVista API)
158  // write a function to delete all subkeys recursively to solve this
159  // or consider letting ReactOS having this API
160 
161  /* Load RegDeleteKeyExW from advapi32.dll if available */
162  if (hMod)
163  {
164  pRegDeleteKeyExW = (RegDeleteKeyExWProc)GetProcAddress(hMod, "RegDeleteKeyExW");
165 
166  if (pRegDeleteKeyExW)
167  {
168  /* Return it */
169  return pRegDeleteKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, szFullName, WowKey, 0);
170  }
171  }
172 
173  /* Otherwise, return non-Ex function */
175 }
#define HKEY_CURRENT_USER
Definition: winreg.h:11
ATL::CStringW szKeyName
Definition: installed.h:14
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1237
LSTATUS(WINAPI * RegDeleteKeyExWProc)(HKEY, LPCWSTR, REGSAM, DWORD)
Definition: installed.cpp:147
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 129 of file installed.cpp.

130 {
131  if (szDisplayIcon.IsEmpty())
132  {
133  return FALSE;
134  }
136  return TRUE;
137 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
bool IsEmpty() const
Definition: atlsimpstr.h:379
ATL::CStringW szDisplayIcon
Definition: installed.h:23

Referenced by CAppsListView::AddInstalledApplication().

◆ UninstallApplication()

BOOL CInstalledApplicationInfo::UninstallApplication ( BOOL  bModify)

Definition at line 139 of file installed.cpp.

140 {
141  if (!bModify)
142  WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_REMOVE, szDisplayName);
143 
144  return StartProcess(bModify ? szModifyPath : szUninstallString, TRUE);
145 }
#define TRUE
Definition: types.h:120
BOOL StartProcess(ATL::CStringW &Path, BOOL Wait)
Definition: misc.cpp:121
ATL::CStringW szDisplayName
Definition: installed.h:24
ATL::CStringW szModifyPath
Definition: installed.h:40
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2701
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:250
ATL::CStringW szUninstallString
Definition: installed.h:39

Referenced by CMainWindow::UninstallSelectedApp().

Member Data Documentation

◆ bIsUpdate

BOOL CInstalledApplicationInfo::bIsUpdate = FALSE

Definition at line 12 of file installed.h.

Referenced by CInstalledApplicationInfo().

◆ hSubKey

HKEY CInstalledApplicationInfo::hSubKey

◆ IsUserKey

BOOL CInstalledApplicationInfo::IsUserKey

Definition at line 9 of file installed.h.

Referenced by RemoveFromRegistry().

◆ szComments

ATL::CStringW CInstalledApplicationInfo::szComments

Definition at line 35 of file installed.h.

Referenced by CAppsListView::AddInstalledApplication().

◆ szContact

ATL::CStringW CInstalledApplicationInfo::szContact

Definition at line 32 of file installed.h.

◆ szDisplayIcon

ATL::CStringW CInstalledApplicationInfo::szDisplayIcon

Definition at line 23 of file installed.h.

Referenced by RetrieveIcon().

◆ szDisplayName

ATL::CStringW CInstalledApplicationInfo::szDisplayName

Definition at line 24 of file installed.h.

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

◆ szDisplayVersion

ATL::CStringW CInstalledApplicationInfo::szDisplayVersion

Definition at line 25 of file installed.h.

Referenced by CAppsListView::AddInstalledApplication().

◆ szHelpLink

ATL::CStringW CInstalledApplicationInfo::szHelpLink

Definition at line 29 of file installed.h.

◆ szHelpTelephone

ATL::CStringW CInstalledApplicationInfo::szHelpTelephone

Definition at line 30 of file installed.h.

◆ szInstallDate

ATL::CStringW CInstalledApplicationInfo::szInstallDate

Definition at line 36 of file installed.h.

◆ szInstallLocation

ATL::CStringW CInstalledApplicationInfo::szInstallLocation

Definition at line 37 of file installed.h.

◆ szInstallSource

ATL::CStringW CInstalledApplicationInfo::szInstallSource

Definition at line 38 of file installed.h.

◆ szKeyName

ATL::CStringW CInstalledApplicationInfo::szKeyName

Definition at line 14 of file installed.h.

Referenced by RemoveFromRegistry().

◆ szModifyPath

ATL::CStringW CInstalledApplicationInfo::szModifyPath

Definition at line 40 of file installed.h.

Referenced by UninstallApplication().

◆ szProductID

ATL::CStringW CInstalledApplicationInfo::szProductID

Definition at line 28 of file installed.h.

◆ szPublisher

ATL::CStringW CInstalledApplicationInfo::szPublisher

Definition at line 26 of file installed.h.

◆ szReadme

ATL::CStringW CInstalledApplicationInfo::szReadme

Definition at line 31 of file installed.h.

◆ szRegOwner

ATL::CStringW CInstalledApplicationInfo::szRegOwner

Definition at line 27 of file installed.h.

◆ szUninstallString

ATL::CStringW CInstalledApplicationInfo::szUninstallString

Definition at line 39 of file installed.h.

Referenced by UninstallApplication().

◆ szURLInfoAbout

ATL::CStringW CInstalledApplicationInfo::szURLInfoAbout

Definition at line 34 of file installed.h.

◆ szURLUpdateInfo

ATL::CStringW CInstalledApplicationInfo::szURLUpdateInfo

Definition at line 33 of file installed.h.

◆ WowKey

REGSAM CInstalledApplicationInfo::WowKey

Definition at line 10 of file installed.h.

Referenced by RemoveFromRegistry().


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