ReactOS  0.4.14-dev-50-g13bb5e2
installed.cpp File Reference
#include "rapps.h"
#include "installed.h"
#include "misc.h"
Include dependency graph for installed.cpp:

Go to the source code of this file.

Functions

BOOL GetApplicationString (HKEY hKey, LPCWSTR lpKeyName, LPWSTR szString)
 
BOOL UninstallApplication (PINSTALLED_INFO ItemInfo, BOOL bModify)
 
BOOL EnumInstalledApplications (INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc, PVOID param)
 

Function Documentation

◆ EnumInstalledApplications()

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

Definition at line 62 of file installed.cpp.

63 {
64  DWORD dwSize = MAX_PATH, dwType, dwValue;
65  BOOL bIsSystemComponent, bIsUpdate;
66  ATL::CStringW szParentKeyName;
67  ATL::CStringW szDisplayName;
69  HKEY hKey;
70  LONG ItemIndex = 0;
71 
72  Info.hRootKey = IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
73 
74  if (RegOpenKeyW(Info.hRootKey,
75  L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
76  &hKey) != ERROR_SUCCESS)
77  {
78  return FALSE;
79  }
80 
81  while (RegEnumKeyExW(hKey, ItemIndex, Info.szKeyName.GetBuffer(MAX_PATH), &dwSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
82  {
83  Info.szKeyName.ReleaseBuffer();
84  if (RegOpenKeyW(hKey, Info.szKeyName.GetString(), &Info.hSubKey) == ERROR_SUCCESS)
85  {
86  dwType = REG_DWORD;
87  dwSize = sizeof(DWORD);
88 
89  if (RegQueryValueExW(Info.hSubKey,
90  L"SystemComponent",
91  NULL,
92  &dwType,
93  (LPBYTE) &dwValue,
94  &dwSize) == ERROR_SUCCESS)
95  {
96  bIsSystemComponent = (dwValue == 0x1);
97  }
98  else
99  {
100  bIsSystemComponent = FALSE;
101  }
102 
103  dwType = REG_SZ;
104  dwSize = MAX_PATH * sizeof(WCHAR);
105  bIsUpdate = (RegQueryValueExW(Info.hSubKey,
106  L"ParentKeyName",
107  NULL,
108  &dwType,
109  (LPBYTE) szParentKeyName.GetBuffer(MAX_PATH),
110  &dwSize) == ERROR_SUCCESS);
111  szParentKeyName.ReleaseBuffer();
112 
113  dwType = REG_SZ;
114  dwSize = MAX_PATH * sizeof(WCHAR);
115  if (RegQueryValueExW(Info.hSubKey,
116  L"DisplayName",
117  NULL,
118  &dwType,
119  (LPBYTE) szDisplayName.GetBuffer(MAX_PATH),
120  &dwSize) == ERROR_SUCCESS)
121  {
122  szDisplayName.ReleaseBuffer();
123  if (EnumType < ENUM_ALL_INSTALLED || EnumType > ENUM_UPDATES)
124  EnumType = ENUM_ALL_INSTALLED;
125 
126  if (!bIsSystemComponent)
127  {
128  if ((EnumType == ENUM_ALL_INSTALLED) || /* All components */
129  ((EnumType == ENUM_INSTALLED_APPLICATIONS) && (!bIsUpdate)) || /* Applications only */
130  ((EnumType == ENUM_UPDATES) && (bIsUpdate))) /* Updates only */
131  {
132  if (!lpEnumProc(ItemIndex, szDisplayName, &Info, param))
133  break;
134  }
135  else
136  {
137  RegCloseKey(Info.hSubKey);
138  }
139  }
140  else
141  {
142  RegCloseKey(Info.hSubKey);
143  }
144  }
145  else
146  {
147  szDisplayName.ReleaseBuffer();
148  RegCloseKey(Info.hSubKey);
149  }
150  }
151 
152  dwSize = MAX_PATH;
153  ItemIndex++;
154  }
155 
156  Info.szKeyName.ReleaseBuffer();
157  RegCloseKey(hKey);
158 
159  return TRUE;
160 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define DWORD
Definition: nt_native.h:44
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
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
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:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
HRESULT GetString(REFGUID guidKey, [out, size_is(cchBufSize)] LPWSTR pwszValue, UINT32 cchBufSize, [in, out, ptr] UINT32 *pcchLength)
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
#define REG_DWORD
Definition: sdbapi.c:596
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by CMainWindow::UpdateApplicationsList().

◆ GetApplicationString()

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

Definition at line 22 of file installed.cpp.

23 {
24  DWORD dwSize = MAX_PATH * sizeof(WCHAR);
25 
26  if (RegQueryValueExW(hKey,
27  lpKeyName,
28  NULL,
29  NULL,
30  (LPBYTE) szString,
31  &dwSize) == ERROR_SUCCESS)
32  {
33  return TRUE;
34  }
35 
36  StringCchCopyW(szString, MAX_PATH, L"---");
37  return FALSE;
38 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
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:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

◆ UninstallApplication()

BOOL UninstallApplication ( PINSTALLED_INFO  ItemInfo,
BOOL  bModify 
)

Definition at line 40 of file installed.cpp.

41 {
42  LPCWSTR szModify = L"ModifyPath";
43  LPCWSTR szUninstall = L"UninstallString";
44  DWORD dwType, dwSize;
46 
47  dwType = REG_SZ;
48  dwSize = MAX_PATH * sizeof(WCHAR);
49  if (RegQueryValueExW(ItemInfo->hSubKey,
50  bModify ? szModify : szUninstall,
51  NULL,
52  &dwType,
53  (LPBYTE) szPath,
54  &dwSize) != ERROR_SUCCESS)
55  {
56  return FALSE;
57  }
58 
59  return StartProcess(szPath, TRUE);
60 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL StartProcess(ATL::CStringW &Path, BOOL Wait)
Definition: misc.cpp:113
unsigned char * LPBYTE
Definition: typedefs.h:52
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:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
HKEY hSubKey
Definition: installed.h:9
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
static const WCHAR szUninstall[]
Definition: registry.c:162
LPCWSTR szPath
Definition: env.c:35
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define REG_SZ
Definition: layer.c:22

Referenced by CMainWindow::UninstallSelectedApp().