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)
12 GetApplicationString(HKEY hKey
, LPWSTR lpKeyName
, LPWSTR lpString
)
14 DWORD dwSize
= MAX_PATH
;
16 if (RegQueryValueExW(hKey
,
21 &dwSize
) == ERROR_SUCCESS
)
26 wcscpy(lpString
, L
"---");
33 IsInstalledApplication(LPWSTR lpRegName
, BOOL IsUserKey
)
35 DWORD dwSize
= MAX_PATH
, dwType
;
36 WCHAR szName
[MAX_PATH
];
37 WCHAR szDisplayName
[MAX_PATH
];
41 if (RegOpenKeyW(IsUserKey
? HKEY_CURRENT_USER
: HKEY_LOCAL_MACHINE
,
42 L
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
43 &hKey
) != ERROR_SUCCESS
)
48 while (RegEnumKeyExW(hKey
, ItemIndex
, szName
, &dwSize
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
50 if (RegOpenKeyW(hKey
, szName
, &hSubKey
) == ERROR_SUCCESS
)
54 if (RegQueryValueExW(hSubKey
,
58 (LPBYTE
)szDisplayName
,
59 &dwSize
) == ERROR_SUCCESS
)
61 if (wcscmp(szDisplayName
, lpRegName
) == 0)
81 UninstallApplication(INT Index
, BOOL bModify
)
83 WCHAR szModify
[] = L
"ModifyPath";
84 WCHAR szUninstall
[] = L
"UninstallString";
85 WCHAR szPath
[MAX_PATH
];
86 WCHAR szAppName
[MAX_STR_LEN
];
91 PINSTALLED_INFO ItemInfo
;
93 if (!IS_INSTALLED_ENUM(SelectedEnumType
))
98 ItemIndex
= (INT
) SendMessageW(hListView
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
107 ListView_GetItemText(hListView
, ItemIndex
, 0, szAppName
, sizeof(szAppName
) / sizeof(WCHAR
));
108 WriteLogMessage(EVENTLOG_SUCCESS
, MSG_SUCCESS_REMOVE
, szAppName
);
110 ZeroMemory(&Item
, sizeof(LVITEM
));
112 Item
.mask
= LVIF_PARAM
;
113 Item
.iItem
= ItemIndex
;
114 if (!ListView_GetItem(hListView
, &Item
))
117 ItemInfo
= (PINSTALLED_INFO
)Item
.lParam
;
118 hKey
= ItemInfo
->hSubKey
;
122 if (RegQueryValueExW(hKey
,
123 bModify
? szModify
: szUninstall
,
127 &dwSize
) != ERROR_SUCCESS
)
132 return StartProcess(szPath
, TRUE
);
137 ShowInstalledAppInfo(INT Index
)
139 WCHAR szText
[MAX_PATH
], szInfo
[MAX_PATH
];
140 PINSTALLED_INFO Info
= ListViewGetlParam(Index
);
142 if (!Info
|| !Info
->hSubKey
) return FALSE
;
144 GetApplicationString(Info
->hSubKey
, L
"DisplayName", szText
);
145 NewRichEditText(szText
, CFE_BOLD
);
147 InsertRichEditText(L
"\n", 0);
149 #define GET_INFO(a, b, c, d) \
150 if (GetApplicationString(Info->hSubKey, a, szInfo)) \
152 LoadStringW(hInst, b, szText, sizeof(szText) / sizeof(WCHAR)); \
153 InsertRichEditText(szText, c); \
154 InsertRichEditText(szInfo, d); \
157 GET_INFO(L"DisplayVersion", IDS_INFO_VERSION, CFE_BOLD, 0);
158 GET_INFO(L
"Publisher", IDS_INFO_PUBLISHER
, CFE_BOLD
, 0);
159 GET_INFO(L
"RegOwner", IDS_INFO_REGOWNER
, CFE_BOLD
, 0);
160 GET_INFO(L
"ProductID", IDS_INFO_PRODUCTID
, CFE_BOLD
, 0);
161 GET_INFO(L
"HelpLink", IDS_INFO_HELPLINK
, CFE_BOLD
, CFM_LINK
);
162 GET_INFO(L
"HelpTelephone", IDS_INFO_HELPPHONE
, CFE_BOLD
, 0);
163 GET_INFO(L
"Readme", IDS_INFO_README
, CFE_BOLD
, 0);
164 GET_INFO(L
"Contact", IDS_INFO_CONTACT
, CFE_BOLD
, 0);
165 GET_INFO(L
"URLUpdateInfo", IDS_INFO_UPDATEINFO
, CFE_BOLD
, CFM_LINK
);
166 GET_INFO(L
"URLInfoAbout", IDS_INFO_INFOABOUT
, CFE_BOLD
, CFM_LINK
);
167 GET_INFO(L
"Comments", IDS_INFO_COMMENTS
, CFE_BOLD
, 0);
168 GET_INFO(L
"InstallDate", IDS_INFO_INSTALLDATE
, CFE_BOLD
, 0);
169 GET_INFO(L
"InstallLocation", IDS_INFO_INSTLOCATION
, CFE_BOLD
, 0);
170 GET_INFO(L
"InstallSource", IDS_INFO_INSTALLSRC
, CFE_BOLD
, 0);
171 GET_INFO(L
"UninstallString", IDS_INFO_UNINSTALLSTR
, CFE_BOLD
, 0);
172 GET_INFO(L
"InstallSource", IDS_INFO_INSTALLSRC
, CFE_BOLD
, 0);
173 GET_INFO(L
"ModifyPath", IDS_INFO_MODIFYPATH
, CFE_BOLD
, 0);
180 RemoveAppFromRegistry(INT Index
)
182 PINSTALLED_INFO Info
;
183 WCHAR szFullName
[MAX_PATH
] = L
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
184 WCHAR szMsgText
[MAX_STR_LEN
], szMsgTitle
[MAX_STR_LEN
];
185 INT ItemIndex
= SendMessage(hListView
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
187 if (!IS_INSTALLED_ENUM(SelectedEnumType
))
190 Info
= ListViewGetlParam(Index
);
191 if (!Info
|| !Info
->hSubKey
|| (ItemIndex
== -1)) return;
193 if (!LoadStringW(hInst
, IDS_APP_REG_REMOVE
, szMsgText
, sizeof(szMsgText
) / sizeof(WCHAR
)) ||
194 !LoadStringW(hInst
, IDS_INFORMATION
, szMsgTitle
, sizeof(szMsgTitle
) / sizeof(WCHAR
)))
197 if (MessageBoxW(hMainWnd
, szMsgText
, szMsgTitle
, MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
199 wcsncat(szFullName
, Info
->szKeyName
, MAX_PATH
- wcslen(szFullName
));
201 if (RegDeleteKeyW(Info
->hRootKey
, szFullName
) == ERROR_SUCCESS
)
203 (VOID
) ListView_DeleteItem(hListView
, ItemIndex
);
207 if (!LoadStringW(hInst
, IDS_UNABLE_TO_REMOVE
, szMsgText
, sizeof(szMsgText
) / sizeof(WCHAR
)))
210 MessageBoxW(hMainWnd
, szMsgText
, NULL
, MB_OK
| MB_ICONERROR
);
216 EnumInstalledApplications(INT EnumType
, BOOL IsUserKey
, APPENUMPROC lpEnumProc
)
218 DWORD dwSize
= MAX_PATH
, dwType
, dwValue
;
219 BOOL bIsSystemComponent
, bIsUpdate
;
220 WCHAR pszParentKeyName
[MAX_PATH
];
221 WCHAR pszDisplayName
[MAX_PATH
];
226 Info
.hRootKey
= IsUserKey
? HKEY_CURRENT_USER
: HKEY_LOCAL_MACHINE
;
228 if (RegOpenKeyW(Info
.hRootKey
,
229 L
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
230 &hKey
) != ERROR_SUCCESS
)
235 while (RegEnumKeyExW(hKey
, ItemIndex
, Info
.szKeyName
, &dwSize
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
237 if (RegOpenKeyW(hKey
, Info
.szKeyName
, &Info
.hSubKey
) == ERROR_SUCCESS
)
240 dwSize
= sizeof(DWORD
);
242 if (RegQueryValueExW(Info
.hSubKey
,
247 &dwSize
) == ERROR_SUCCESS
)
249 bIsSystemComponent
= (dwValue
== 0x1);
253 bIsSystemComponent
= FALSE
;
258 bIsUpdate
= (RegQueryValueExW(Info
.hSubKey
,
262 (LPBYTE
)pszParentKeyName
,
263 &dwSize
) == ERROR_SUCCESS
);
266 if (RegQueryValueExW(Info
.hSubKey
,
270 (LPBYTE
)pszDisplayName
,
271 &dwSize
) == ERROR_SUCCESS
)
273 if (EnumType
< ENUM_ALL_COMPONENTS
|| EnumType
> ENUM_UPDATES
)
274 EnumType
= ENUM_ALL_COMPONENTS
;
276 if (!bIsSystemComponent
)
278 if ((EnumType
== ENUM_ALL_COMPONENTS
) || /* All components */
279 ((EnumType
== ENUM_APPLICATIONS
) && (!bIsUpdate
)) || /* Applications only */
280 ((EnumType
== ENUM_UPDATES
) && (bIsUpdate
))) /* Updates only */
282 if (!lpEnumProc(ItemIndex
, pszDisplayName
, Info
))