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
];
92 if (!IS_INSTALLED_ENUM(SelectedEnumType
))
97 ItemIndex
= (INT
) SendMessageW(hListView
, LVM_GETNEXTITEM
, -1, LVNI_FOCUSED
);
106 ZeroMemory(&Item
, sizeof(LVITEM
));
108 Item
.mask
= LVIF_PARAM
;
109 Item
.iItem
= ItemIndex
;
110 if (!ListView_GetItem(hListView
, &Item
))
113 hKey
= (HKEY
)Item
.lParam
;
117 if (RegQueryValueExW(hKey
,
118 bModify
? szModify
: szUninstall
,
122 &dwSize
) != ERROR_SUCCESS
)
127 return StartProcess(szPath
, TRUE
);
132 ShowInstalledAppInfo(INT Index
)
134 WCHAR szText
[MAX_PATH
], szInfo
[MAX_PATH
];
135 HKEY hKey
= (HKEY
) ListViewGetlParam(Index
);
137 if (!hKey
) return FALSE
;
139 GetApplicationString(hKey
, L
"DisplayName", szText
);
140 NewRichEditText(szText
, CFE_BOLD
);
142 InsertRichEditText(L
"\n", 0);
144 #define GET_INFO(a, b, c, d) \
145 if (GetApplicationString(hKey, a, szInfo)) \
147 LoadStringW(hInst, b, szText, sizeof(szText) / sizeof(WCHAR)); \
148 InsertRichEditText(szText, c); \
149 InsertRichEditText(szInfo, d); \
152 GET_INFO(L"DisplayVersion", IDS_INFO_VERSION, CFE_BOLD, 0);
153 GET_INFO(L
"Publisher", IDS_INFO_PUBLISHER
, CFE_BOLD
, 0);
154 GET_INFO(L
"RegOwner", IDS_INFO_REGOWNER
, CFE_BOLD
, 0);
155 GET_INFO(L
"ProductID", IDS_INFO_PRODUCTID
, CFE_BOLD
, 0);
156 GET_INFO(L
"HelpLink", IDS_INFO_HELPLINK
, CFE_BOLD
, CFM_LINK
);
157 GET_INFO(L
"HelpTelephone", IDS_INFO_HELPPHONE
, CFE_BOLD
, 0);
158 GET_INFO(L
"Readme", IDS_INFO_README
, CFE_BOLD
, 0);
159 GET_INFO(L
"Contact", IDS_INFO_CONTACT
, CFE_BOLD
, 0);
160 GET_INFO(L
"URLUpdateInfo", IDS_INFO_UPDATEINFO
, CFE_BOLD
, CFM_LINK
);
161 GET_INFO(L
"URLInfoAbout", IDS_INFO_INFOABOUT
, CFE_BOLD
, CFM_LINK
);
162 GET_INFO(L
"Comments", IDS_INFO_COMMENTS
, CFE_BOLD
, 0);
163 GET_INFO(L
"InstallDate", IDS_INFO_INSTALLDATE
, CFE_BOLD
, 0);
164 GET_INFO(L
"InstallLocation", IDS_INFO_INSTLOCATION
, CFE_BOLD
, 0);
165 GET_INFO(L
"InstallSource", IDS_INFO_INSTALLSRC
, CFE_BOLD
, 0);
166 GET_INFO(L
"UninstallString", IDS_INFO_UNINSTALLSTR
, CFE_BOLD
, 0);
167 GET_INFO(L
"InstallSource", IDS_INFO_INSTALLSRC
, CFE_BOLD
, 0);
168 GET_INFO(L
"ModifyPath", IDS_INFO_MODIFYPATH
, CFE_BOLD
, 0);
175 EnumInstalledApplications(INT EnumType
, BOOL IsUserKey
, APPENUMPROC lpEnumProc
)
177 DWORD dwSize
= MAX_PATH
, dwType
, dwValue
;
178 BOOL bIsSystemComponent
, bIsUpdate
;
179 WCHAR pszName
[MAX_PATH
];
180 WCHAR pszParentKeyName
[MAX_PATH
];
181 WCHAR pszDisplayName
[MAX_PATH
];
185 if (RegOpenKeyW(IsUserKey
? HKEY_CURRENT_USER
: HKEY_LOCAL_MACHINE
,
186 L
"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall",
187 &hKey
) != ERROR_SUCCESS
)
192 while (RegEnumKeyExW(hKey
, ItemIndex
, pszName
, &dwSize
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
194 if (RegOpenKeyW(hKey
, pszName
, &hSubKey
) == ERROR_SUCCESS
)
197 dwSize
= sizeof(DWORD
);
199 if (RegQueryValueExW(hSubKey
,
204 &dwSize
) == ERROR_SUCCESS
)
206 bIsSystemComponent
= (dwValue
== 0x1);
210 bIsSystemComponent
= FALSE
;
215 bIsUpdate
= (RegQueryValueExW(hSubKey
,
219 (LPBYTE
)pszParentKeyName
,
220 &dwSize
) == ERROR_SUCCESS
);
223 if (RegQueryValueExW(hSubKey
,
227 (LPBYTE
)pszDisplayName
,
228 &dwSize
) == ERROR_SUCCESS
)
230 if (EnumType
< ENUM_ALL_COMPONENTS
|| EnumType
> ENUM_UPDATES
)
231 EnumType
= ENUM_ALL_COMPONENTS
;
233 if (!bIsSystemComponent
)
235 if ((EnumType
== ENUM_ALL_COMPONENTS
) || /* All components */
236 ((EnumType
== ENUM_APPLICATIONS
) && (!bIsUpdate
)) || /* Applications only */
237 ((EnumType
== ENUM_UPDATES
) && (bIsUpdate
))) /* Updates only */
239 if (!lpEnumProc(ItemIndex
, pszDisplayName
, pszName
, (LPARAM
)hSubKey
))