2 * PROJECT: ReactOS Applications Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: base/applications/rapps/installed.c
5 * PURPOSE: Functions for working with installed applications
6 * PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
13 GetApplicationString(HKEY hKey
, LPWSTR lpKeyName
, LPWSTR lpString
)
15 DWORD dwSize
= MAX_PATH
;
17 if (RegQueryValueExW(hKey
,
22 &dwSize
) == ERROR_SUCCESS
)
27 wcscpy(lpString
, L
"---");
34 IsInstalledApplication(LPWSTR lpRegName
, BOOL IsUserKey
)
36 DWORD dwSize
= MAX_PATH
, dwType
;
37 WCHAR szName
[MAX_PATH
];
38 WCHAR szDisplayName
[MAX_PATH
];
42 if (RegOpenKeyW(IsUserKey
? HKEY_CURRENT_USER
: HKEY_LOCAL_MACHINE
,
43 L
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
44 &hKey
) != ERROR_SUCCESS
)
49 while (RegEnumKeyExW(hKey
, ItemIndex
, szName
, &dwSize
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
51 if (RegOpenKeyW(hKey
, szName
, &hSubKey
) == ERROR_SUCCESS
)
55 if (RegQueryValueExW(hSubKey
,
59 (LPBYTE
)szDisplayName
,
60 &dwSize
) == ERROR_SUCCESS
)
62 if (wcscmp(szDisplayName
, lpRegName
) == 0)
82 UninstallApplication(INT Index
, BOOL bModify
)
84 WCHAR szModify
[] = L
"ModifyPath";
85 WCHAR szUninstall
[] = L
"UninstallString";
86 WCHAR szPath
[MAX_PATH
];
87 WCHAR szAppName
[MAX_STR_LEN
];
92 PINSTALLED_INFO ItemInfo
;
94 if (!IS_INSTALLED_ENUM(SelectedEnumType
))
99 ItemIndex
= (INT
) SendMessageW(hListView
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
108 ListView_GetItemText(hListView
, ItemIndex
, 0, szAppName
, sizeof(szAppName
) / sizeof(WCHAR
));
109 WriteLogMessage(EVENTLOG_SUCCESS
, MSG_SUCCESS_REMOVE
, szAppName
);
111 ZeroMemory(&Item
, sizeof(LVITEM
));
113 Item
.mask
= LVIF_PARAM
;
114 Item
.iItem
= ItemIndex
;
115 if (!ListView_GetItem(hListView
, &Item
))
118 ItemInfo
= (PINSTALLED_INFO
)Item
.lParam
;
119 hKey
= ItemInfo
->hSubKey
;
123 if (RegQueryValueExW(hKey
,
124 bModify
? szModify
: szUninstall
,
128 &dwSize
) != ERROR_SUCCESS
)
133 return StartProcess(szPath
, TRUE
);
138 ShowInstalledAppInfo(INT Index
)
140 WCHAR szText
[MAX_PATH
], szInfo
[MAX_PATH
];
141 PINSTALLED_INFO Info
= ListViewGetlParam(Index
);
143 if (!Info
|| !Info
->hSubKey
) return FALSE
;
145 GetApplicationString(Info
->hSubKey
, L
"DisplayName", szText
);
146 NewRichEditText(szText
, CFE_BOLD
);
148 InsertRichEditText(L
"\n", 0);
150 #define GET_INFO(a, b, c, d) \
151 if (GetApplicationString(Info->hSubKey, a, szInfo)) \
153 LoadStringW(hInst, b, szText, sizeof(szText) / sizeof(WCHAR)); \
154 InsertRichEditText(szText, c); \
155 InsertRichEditText(szInfo, d); \
158 GET_INFO(L"DisplayVersion", IDS_INFO_VERSION, CFE_BOLD, 0);
159 GET_INFO(L
"Publisher", IDS_INFO_PUBLISHER
, CFE_BOLD
, 0);
160 GET_INFO(L
"RegOwner", IDS_INFO_REGOWNER
, CFE_BOLD
, 0);
161 GET_INFO(L
"ProductID", IDS_INFO_PRODUCTID
, CFE_BOLD
, 0);
162 GET_INFO(L
"HelpLink", IDS_INFO_HELPLINK
, CFE_BOLD
, CFM_LINK
);
163 GET_INFO(L
"HelpTelephone", IDS_INFO_HELPPHONE
, CFE_BOLD
, 0);
164 GET_INFO(L
"Readme", IDS_INFO_README
, CFE_BOLD
, 0);
165 GET_INFO(L
"Contact", IDS_INFO_CONTACT
, CFE_BOLD
, 0);
166 GET_INFO(L
"URLUpdateInfo", IDS_INFO_UPDATEINFO
, CFE_BOLD
, CFM_LINK
);
167 GET_INFO(L
"URLInfoAbout", IDS_INFO_INFOABOUT
, CFE_BOLD
, CFM_LINK
);
168 GET_INFO(L
"Comments", IDS_INFO_COMMENTS
, CFE_BOLD
, 0);
169 GET_INFO(L
"InstallDate", IDS_INFO_INSTALLDATE
, CFE_BOLD
, 0);
170 GET_INFO(L
"InstallLocation", IDS_INFO_INSTLOCATION
, CFE_BOLD
, 0);
171 GET_INFO(L
"InstallSource", IDS_INFO_INSTALLSRC
, CFE_BOLD
, 0);
172 GET_INFO(L
"UninstallString", IDS_INFO_UNINSTALLSTR
, CFE_BOLD
, 0);
173 GET_INFO(L
"InstallSource", IDS_INFO_INSTALLSRC
, CFE_BOLD
, 0);
174 GET_INFO(L
"ModifyPath", IDS_INFO_MODIFYPATH
, CFE_BOLD
, 0);
181 RemoveAppFromRegistry(INT Index
)
183 PINSTALLED_INFO Info
;
184 WCHAR szFullName
[MAX_PATH
] = L
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
185 WCHAR szMsgText
[MAX_STR_LEN
], szMsgTitle
[MAX_STR_LEN
];
186 INT ItemIndex
= SendMessage(hListView
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
188 if (!IS_INSTALLED_ENUM(SelectedEnumType
))
191 Info
= ListViewGetlParam(Index
);
192 if (!Info
|| !Info
->hSubKey
|| (ItemIndex
== -1)) return;
194 if (!LoadStringW(hInst
, IDS_APP_REG_REMOVE
, szMsgText
, sizeof(szMsgText
) / sizeof(WCHAR
)) ||
195 !LoadStringW(hInst
, IDS_INFORMATION
, szMsgTitle
, sizeof(szMsgTitle
) / sizeof(WCHAR
)))
198 if (MessageBoxW(hMainWnd
, szMsgText
, szMsgTitle
, MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
200 wcsncat(szFullName
, Info
->szKeyName
, MAX_PATH
- wcslen(szFullName
));
202 if (RegDeleteKeyW(Info
->hRootKey
, szFullName
) == ERROR_SUCCESS
)
204 (VOID
) ListView_DeleteItem(hListView
, ItemIndex
);
208 if (!LoadStringW(hInst
, IDS_UNABLE_TO_REMOVE
, szMsgText
, sizeof(szMsgText
) / sizeof(WCHAR
)))
211 MessageBoxW(hMainWnd
, szMsgText
, NULL
, MB_OK
| MB_ICONERROR
);
217 EnumInstalledApplications(INT EnumType
, BOOL IsUserKey
, APPENUMPROC lpEnumProc
)
219 DWORD dwSize
= MAX_PATH
, dwType
, dwValue
;
220 BOOL bIsSystemComponent
, bIsUpdate
;
221 WCHAR pszParentKeyName
[MAX_PATH
];
222 WCHAR pszDisplayName
[MAX_PATH
];
227 Info
.hRootKey
= IsUserKey
? HKEY_CURRENT_USER
: HKEY_LOCAL_MACHINE
;
229 if (RegOpenKeyW(Info
.hRootKey
,
230 L
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
231 &hKey
) != ERROR_SUCCESS
)
236 while (RegEnumKeyExW(hKey
, ItemIndex
, Info
.szKeyName
, &dwSize
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
238 if (RegOpenKeyW(hKey
, Info
.szKeyName
, &Info
.hSubKey
) == ERROR_SUCCESS
)
241 dwSize
= sizeof(DWORD
);
243 if (RegQueryValueExW(Info
.hSubKey
,
248 &dwSize
) == ERROR_SUCCESS
)
250 bIsSystemComponent
= (dwValue
== 0x1);
254 bIsSystemComponent
= FALSE
;
259 bIsUpdate
= (RegQueryValueExW(Info
.hSubKey
,
263 (LPBYTE
)pszParentKeyName
,
264 &dwSize
) == ERROR_SUCCESS
);
267 if (RegQueryValueExW(Info
.hSubKey
,
271 (LPBYTE
)pszDisplayName
,
272 &dwSize
) == ERROR_SUCCESS
)
274 if (EnumType
< ENUM_ALL_COMPONENTS
|| EnumType
> ENUM_UPDATES
)
275 EnumType
= ENUM_ALL_COMPONENTS
;
277 if (!bIsSystemComponent
)
279 if ((EnumType
== ENUM_ALL_COMPONENTS
) || /* All components */
280 ((EnumType
== ENUM_APPLICATIONS
) && (!bIsUpdate
)) || /* Applications only */
281 ((EnumType
== ENUM_UPDATES
) && (bIsUpdate
))) /* Updates only */
283 if (!lpEnumProc(ItemIndex
, pszDisplayName
, Info
))