ReactOS  0.4.12-dev-43-g63b00d8
installed.cpp File Reference
#include "rapps.h"
#include "installed.h"
#include "gui.h"
#include "misc.h"
Include dependency graph for installed.cpp:

Go to the source code of this file.

Macros

#define GET_INFO(a, b, c, d)
 

Functions

BOOL GetApplicationString (HKEY hKey, LPCWSTR lpKeyName, ATL::CStringW &String)
 
BOOL GetApplicationString (HKEY hKey, LPCWSTR lpKeyName, LPWSTR szString)
 
BOOL UninstallApplication (INT Index, BOOL bModify)
 
BOOL ShowInstalledAppInfo (INT Index)
 
VOID RemoveAppFromRegistry (INT Index)
 
BOOL EnumInstalledApplications (INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc)
 

Macro Definition Documentation

◆ GET_INFO

#define GET_INFO (   a,
  b,
  c,
  d 
)
Value:
if (GetApplicationString(Info->hSubKey, a, szInfo)) \
{ \
szText.LoadStringW(b); \
InsertRichEditText(szText, c); \
InsertRichEditText(szInfo, d); \
} \
struct TraceInfo Info
static const WCHAR szText[]
Definition: dialog.c:139
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define d
Definition: ke_i.h:81
BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, ATL::CStringW &String)
Definition: installed.cpp:16
const GLubyte * c
Definition: glext.h:8905
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by ShowInstalledAppInfo().

Function Documentation

◆ EnumInstalledApplications()

BOOL EnumInstalledApplications ( INT  EnumType,
BOOL  IsUserKey,
APPENUMPROC  lpEnumProc 
)

Definition at line 173 of file installed.cpp.

Referenced by CMainWindow::UpdateApplicationsList().

174 {
175  DWORD dwSize = MAX_PATH, dwType, dwValue;
176  BOOL bIsSystemComponent, bIsUpdate;
177  ATL::CStringW szParentKeyName;
178  ATL::CStringW szDisplayName;
180  HKEY hKey;
181  LONG ItemIndex = 0;
182 
183  Info.hRootKey = IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
184 
185  if (RegOpenKeyW(Info.hRootKey,
186  L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
187  &hKey) != ERROR_SUCCESS)
188  {
189  return FALSE;
190  }
191 
192  while (RegEnumKeyExW(hKey, ItemIndex, Info.szKeyName.GetBuffer(MAX_PATH), &dwSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
193  {
194  Info.szKeyName.ReleaseBuffer();
195  if (RegOpenKeyW(hKey, Info.szKeyName.GetString(), &Info.hSubKey) == ERROR_SUCCESS)
196  {
197  dwType = REG_DWORD;
198  dwSize = sizeof(DWORD);
199 
200  if (RegQueryValueExW(Info.hSubKey,
201  L"SystemComponent",
202  NULL,
203  &dwType,
204  (LPBYTE) &dwValue,
205  &dwSize) == ERROR_SUCCESS)
206  {
207  bIsSystemComponent = (dwValue == 0x1);
208  }
209  else
210  {
211  bIsSystemComponent = FALSE;
212  }
213 
214  dwType = REG_SZ;
215  dwSize = MAX_PATH * sizeof(WCHAR);
216  bIsUpdate = (RegQueryValueExW(Info.hSubKey,
217  L"ParentKeyName",
218  NULL,
219  &dwType,
220  (LPBYTE) szParentKeyName.GetBuffer(MAX_PATH),
221  &dwSize) == ERROR_SUCCESS);
222  szParentKeyName.ReleaseBuffer();
223 
224  dwType = REG_SZ;
225  dwSize = MAX_PATH * sizeof(WCHAR);
226  if (RegQueryValueExW(Info.hSubKey,
227  L"DisplayName",
228  NULL,
229  &dwType,
230  (LPBYTE) szDisplayName.GetBuffer(MAX_PATH),
231  &dwSize) == ERROR_SUCCESS)
232  {
233  szDisplayName.ReleaseBuffer();
234  if (EnumType < ENUM_ALL_INSTALLED || EnumType > ENUM_UPDATES)
235  EnumType = ENUM_ALL_INSTALLED;
236 
237  if (!bIsSystemComponent)
238  {
239  if ((EnumType == ENUM_ALL_INSTALLED) || /* All components */
240  ((EnumType == ENUM_INSTALLED_APPLICATIONS) && (!bIsUpdate)) || /* Applications only */
241  ((EnumType == ENUM_UPDATES) && (bIsUpdate))) /* Updates only */
242  {
243  if (!lpEnumProc(ItemIndex, szDisplayName, &Info))
244  break;
245  }
246  else
247  {
248  RegCloseKey(Info.hSubKey);
249  }
250  }
251  else
252  {
253  RegCloseKey(Info.hSubKey);
254  }
255  }
256  else
257  {
258  szDisplayName.ReleaseBuffer();
259  RegCloseKey(Info.hSubKey);
260  }
261  }
262 
263  dwSize = MAX_PATH;
264  ItemIndex++;
265  }
266 
267  Info.szKeyName.ReleaseBuffer();
268  RegCloseKey(hKey);
269 
270  return TRUE;
271 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DWORD
Definition: msvc.h:34
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define WCHAR
Definition: msvc.h:43
struct TraceInfo Info
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
ATL::CStringW szKeyName
Definition: installed.h:10
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
smooth NULL
Definition: ftsmooth.c:416
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:4134
HKEY hSubKey
Definition: installed.h:9
#define MAX_PATH
Definition: compat.h:26
PCXSTR GetString() const
Definition: atlsimpstr.h:361
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
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:2541
HKEY hRootKey
Definition: installed.h:8
#define REG_DWORD
Definition: sdbapi.c:539
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

◆ GetApplicationString() [1/2]

BOOL GetApplicationString ( HKEY  hKey,
LPCWSTR  lpKeyName,
ATL::CStringW String 
)

Definition at line 16 of file installed.cpp.

Referenced by ShowInstalledAppInfo().

17 {
18  BOOL result = GetApplicationString(hKey, lpKeyName, String.GetBuffer(MAX_PATH));
19  String.ReleaseBuffer();
20  return result;
21 }
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, ATL::CStringW &String)
Definition: installed.cpp:16
#define MAX_PATH
Definition: compat.h:26
GLuint64EXT * result
Definition: glext.h:11304

◆ GetApplicationString() [2/2]

BOOL GetApplicationString ( HKEY  hKey,
LPCWSTR  lpKeyName,
LPWSTR  szString 
)

Definition at line 23 of file installed.cpp.

Referenced by CMainWindow::s_EnumInstalledAppProc().

24 {
25  DWORD dwSize = MAX_PATH * sizeof(WCHAR);
26 
27  if (RegQueryValueExW(hKey,
28  lpKeyName,
29  NULL,
30  NULL,
31  (LPBYTE) szString,
32  &dwSize) == ERROR_SUCCESS)
33  {
34  return TRUE;
35  }
36 
37  StringCchCopyW(szString, MAX_PATH, L"---");
38  return FALSE;
39 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define WCHAR
Definition: msvc.h:43
unsigned char * LPBYTE
Definition: typedefs.h:52
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1087
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

◆ RemoveAppFromRegistry()

VOID RemoveAppFromRegistry ( INT  Index)

Definition at line 136 of file installed.cpp.

Referenced by CMainWindow::OnCommand().

137 {
139  WCHAR szFullName[MAX_PATH] = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
140  ATL::CStringW szMsgText, szMsgTitle;
142 
144  return;
145 
147  if (!Info || !Info->hSubKey || (ItemIndex == -1)) return;
148 
149  if (!szMsgText.LoadStringW(IDS_APP_REG_REMOVE) ||
150  !szMsgTitle.LoadStringW(IDS_INFORMATION))
151  return;
152 
153  if (MessageBoxW(hMainWnd, szMsgText, szMsgTitle, MB_YESNO | MB_ICONQUESTION) == IDYES)
154  {
155  ATL::CStringW::CopyChars(szFullName,
156  MAX_PATH,
157  Info->szKeyName.GetString(),
158  MAX_PATH - wcslen(szFullName));
159 
160  if (RegDeleteKeyW(Info->hRootKey, szFullName) == ERROR_SUCCESS)
161  {
162  ListView_DeleteItem(hListView, ItemIndex);
163  return;
164  }
165 
166  if (!szMsgText.LoadStringW(IDS_UNABLE_TO_REMOVE))
167  return;
168 
170  }
171 }
DWORD_PTR ListViewGetlParam(INT item)
Definition: gui.cpp:1773
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDYES
Definition: winuser.h:829
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1240
#define IDS_UNABLE_TO_REMOVE
Definition: resource.h:102
int32_t INT
Definition: typedefs.h:56
struct TraceInfo Info
#define MB_YESNO
Definition: winuser.h:811
ATL::CStringW szKeyName
Definition: installed.h:10
smooth NULL
Definition: ftsmooth.c:416
#define MB_ICONQUESTION
Definition: winuser.h:783
#define ListView_DeleteItem(hwnd, i)
Definition: commctrl.h:2381
#define LVNI_FOCUSED
Definition: commctrl.h:2393
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
HKEY hSubKey
Definition: installed.h:9
#define MAX_PATH
Definition: compat.h:26
PCXSTR GetString() const
Definition: atlsimpstr.h:361
static const UCHAR Index[8]
Definition: usbohci.c:18
BOOL IsInstalledEnum(INT x)
Definition: defines.h:68
HWND hMainWnd
Definition: magnifier.c:33
static const WCHAR L[]
Definition: oid.c:1087
#define MB_ICONERROR
Definition: winuser.h:781
INSTALLED_INFO * PINSTALLED_INFO
Definition: installed.h:13
HWND hListView
Definition: gui.cpp:29
#define IDS_APP_REG_REMOVE
Definition: resource.h:100
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static void __cdecl CopyChars(_Out_writes_to_(nDestLen, nChars) XCHAR *pchDest, _In_ size_t nDestLen, _In_reads_opt_(nChars) const XCHAR *pchSrc, _In_ int nChars)
Definition: atlsimpstr.h:423
#define MB_OK
Definition: winuser.h:784
#define IDS_INFORMATION
Definition: resource.h:101
INT SelectedEnumType
Definition: winmain.cpp:18
HKEY hRootKey
Definition: installed.h:8
#define LVM_GETNEXTITEM
Definition: commctrl.h:2403
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ ShowInstalledAppInfo()

BOOL ShowInstalledAppInfo ( INT  Index)

Definition at line 95 of file installed.cpp.

Referenced by CMainWindow::ProcessWindowMessage().

96 {
98  ATL::CStringW szInfo;
100 
101  if (!Info || !Info->hSubKey) return FALSE;
102 
103  GetApplicationString(Info->hSubKey, L"DisplayName", szText);
104  NewRichEditText(szText, CFE_BOLD);
105  InsertRichEditText(L"\n", 0);
106 
107 #define GET_INFO(a, b, c, d) \
108  if (GetApplicationString(Info->hSubKey, a, szInfo)) \
109  { \
110  szText.LoadStringW(b); \
111  InsertRichEditText(szText, c); \
112  InsertRichEditText(szInfo, d); \
113  } \
114 
115  GET_INFO(L"DisplayVersion", IDS_INFO_VERSION, CFE_BOLD, 0);
116  GET_INFO(L"Publisher", IDS_INFO_PUBLISHER, CFE_BOLD, 0);
117  GET_INFO(L"RegOwner", IDS_INFO_REGOWNER, CFE_BOLD, 0);
118  GET_INFO(L"ProductID", IDS_INFO_PRODUCTID, CFE_BOLD, 0);
120  GET_INFO(L"HelpTelephone", IDS_INFO_HELPPHONE, CFE_BOLD, 0);
121  GET_INFO(L"Readme", IDS_INFO_README, CFE_BOLD, 0);
122  GET_INFO(L"Contact", IDS_INFO_CONTACT, CFE_BOLD, 0);
123  GET_INFO(L"URLUpdateInfo", IDS_INFO_UPDATEINFO, CFE_BOLD, CFM_LINK);
124  GET_INFO(L"URLInfoAbout", IDS_INFO_INFOABOUT, CFE_BOLD, CFM_LINK);
125  GET_INFO(L"Comments", IDS_INFO_COMMENTS, CFE_BOLD, 0);
126  GET_INFO(L"InstallDate", IDS_INFO_INSTALLDATE, CFE_BOLD, 0);
127  GET_INFO(L"InstallLocation", IDS_INFO_INSTLOCATION, CFE_BOLD, 0);
128  GET_INFO(L"InstallSource", IDS_INFO_INSTALLSRC, CFE_BOLD, 0);
129  GET_INFO(L"UninstallString", IDS_INFO_UNINSTALLSTR, CFE_BOLD, 0);
130  GET_INFO(L"InstallSource", IDS_INFO_INSTALLSRC, CFE_BOLD, 0);
131  GET_INFO(L"ModifyPath", IDS_INFO_MODIFYPATH, CFE_BOLD, 0);
132 
133  return TRUE;
134 }
#define GET_INFO(a, b, c, d)
#define IDS_INFO_INSTALLDATE
Definition: resource.h:147
#define IDS_INFO_PUBLISHER
Definition: resource.h:133
DWORD_PTR ListViewGetlParam(INT item)
Definition: gui.cpp:1773
#define TRUE
Definition: types.h:120
VOID NewRichEditText(LPCWSTR szText, DWORD flags)
Definition: gui.cpp:1792
#define IDS_INFO_INSTALLSRC
Definition: resource.h:144
#define IDS_INFO_README
Definition: resource.h:136
struct TraceInfo Info
#define CFE_BOLD
Definition: richedit.h:406
#define IDS_INFO_COMMENTS
Definition: resource.h:142
static const WCHAR szText[]
Definition: dialog.c:139
#define IDS_INFO_CONTACT
Definition: resource.h:139
HKEY hSubKey
Definition: installed.h:9
BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, ATL::CStringW &String)
Definition: installed.cpp:16
static const UCHAR Index[8]
Definition: usbohci.c:18
#define IDS_INFO_VERSION
Definition: resource.h:131
VOID InsertRichEditText(LPCWSTR szText, DWORD flags)
Definition: gui.cpp:1797
static const WCHAR L[]
Definition: oid.c:1087
#define CFM_LINK
Definition: richedit.h:337
#define IDS_INFO_UNINSTALLSTR
Definition: resource.h:145
#define IDS_INFO_UPDATEINFO
Definition: resource.h:140
INSTALLED_INFO * PINSTALLED_INFO
Definition: installed.h:13
#define IDS_INFO_PRODUCTID
Definition: resource.h:138
#define IDS_INFO_HELPPHONE
Definition: resource.h:135
#define IDS_INFO_MODIFYPATH
Definition: resource.h:146
#define IDS_INFO_INSTLOCATION
Definition: resource.h:143
#define IDS_INFO_HELPLINK
Definition: resource.h:134
#define IDS_INFO_REGOWNER
Definition: resource.h:137
#define IDS_INFO_INFOABOUT
Definition: resource.h:141

◆ UninstallApplication()

BOOL UninstallApplication ( INT  Index,
BOOL  bModify 
)

Definition at line 41 of file installed.cpp.

Referenced by CMainWindow::OnCommand().

42 {
43  LPCWSTR szModify = L"ModifyPath";
44  LPCWSTR szUninstall = L"UninstallString";
47  DWORD dwType, dwSize;
48  INT ItemIndex;
49  LVITEMW Item;
50  HKEY hKey;
51  PINSTALLED_INFO ItemInfo;
52 
54  return FALSE;
55 
56  if (Index == -1)
57  {
59  if (ItemIndex == -1)
60  return FALSE;
61  }
62  else
63  {
64  ItemIndex = Index;
65  }
66 
67  ListView_GetItemText(hListView, ItemIndex, 0, szAppName, _countof(szAppName));
68  WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_REMOVE, szAppName);
69 
70  ZeroMemory(&Item, sizeof(Item));
71 
72  Item.mask = LVIF_PARAM;
73  Item.iItem = ItemIndex;
74  if (!ListView_GetItem(hListView, &Item))
75  return FALSE;
76 
77  ItemInfo = (PINSTALLED_INFO) Item.lParam;
78  hKey = ItemInfo->hSubKey;
79 
80  dwType = REG_SZ;
81  dwSize = MAX_PATH * sizeof(WCHAR);
82  if (RegQueryValueExW(hKey,
83  bModify ? szModify : szUninstall,
84  NULL,
85  &dwType,
86  (LPBYTE) szPath,
87  &dwSize) != ERROR_SUCCESS)
88  {
89  return FALSE;
90  }
91 
92  return StartProcess(szPath, TRUE);
93 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: fontsub.cpp:30
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2654
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define ZeroMemory
Definition: winbase.h:1635
int32_t INT
Definition: typedefs.h:56
BOOL StartProcess(ATL::CStringW &Path, BOOL Wait)
Definition: misc.cpp:128
unsigned char * LPBYTE
Definition: typedefs.h:52
LPARAM lParam
Definition: commctrl.h:2338
#define INT(a)
Definition: assyntax.h:463
smooth NULL
Definition: ftsmooth.c:416
#define LVNI_FOCUSED
Definition: commctrl.h:2393
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2629
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:256
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
HKEY hSubKey
Definition: installed.h:9
#define MAX_PATH
Definition: compat.h:26
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL IsInstalledEnum(INT x)
Definition: defines.h:68
UINT mask
Definition: commctrl.h:2330
static const WCHAR L[]
Definition: oid.c:1087
TCHAR szAppName[128]
Definition: solitaire.cpp:16
static const WCHAR szUninstall[]
Definition: registry.c:162
INSTALLED_INFO * PINSTALLED_INFO
Definition: installed.h:13
HWND hListView
Definition: gui.cpp:29
LPCWSTR szPath
Definition: env.c:35
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MAX_STR_LEN
Definition: defines.h:33
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2364
#define LVIF_PARAM
Definition: commctrl.h:2281
INT SelectedEnumType
Definition: winmain.cpp:18
#define LVM_GETNEXTITEM
Definition: commctrl.h:2403
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define REG_SZ
Definition: layer.c:22