mirror of
https://github.com/reactos/reactos.git
synced 2025-06-03 08:20:27 +00:00
[RAPPS]
* Reduced "installed" check - checks only for the key inself and not the DisplayName. Blazing fast! * Added installed version getter * Added version parser function (without definition yet). Meant to support versions like 1.2.3.4. * rapps.h: Added #pragma once svn path=/branches/GSoC_2017/rapps/; revision=75211
This commit is contained in:
parent
5582a642ef
commit
928e1c0ba3
4 changed files with 80 additions and 37 deletions
|
@ -40,11 +40,14 @@ inline void _GetStringNullFailure(LPCWSTR a, T(&b)[N], T (&cFileName)[N2]) {
|
|||
}
|
||||
}
|
||||
|
||||
//App is "installed" if the RegName is in the registry
|
||||
inline bool _AppInstallCheckKey(PAPPLICATION_INFO Info, REGSAM key) {
|
||||
return *Info->szRegName
|
||||
&& (IsInstalledApplicationEx(Info->szRegName, TRUE, key)
|
||||
|| IsInstalledApplicationEx(Info->szRegName, FALSE, key));
|
||||
//App is "installed" if the RegName or Name is in the registry
|
||||
inline bool _AppInstallCheckKey(PAPPLICATION_INFO Info, REGSAM key)
|
||||
{
|
||||
return (*Info->szRegName
|
||||
&& (IsInstalledApplication(Info->szRegName, TRUE, key)
|
||||
|| IsInstalledApplication(Info->szRegName, FALSE, key)))
|
||||
|| (*Info->szName && (IsInstalledApplication(Info->szName, TRUE, key)
|
||||
|| IsInstalledApplication(Info->szName, FALSE, key)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,50 +28,59 @@ GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR lpString)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL
|
||||
IsInstalledApplicationEx(LPWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow)
|
||||
IsInstalledApplication(LPCWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow)
|
||||
{
|
||||
DWORD dwSize = MAX_PATH, dwType;
|
||||
WCHAR szName[MAX_PATH];
|
||||
WCHAR szDisplayName[MAX_PATH];
|
||||
HKEY hKey = NULL;
|
||||
BOOL IsInstalled = FALSE;
|
||||
|
||||
if ((RegOpenKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, keyWow | KEY_ENUMERATE_SUB_KEYS,
|
||||
&hKey) == ERROR_SUCCESS) \
|
||||
&& FindRegistryKeyByName(hKey, keyWow, lpRegName, NULL))
|
||||
{
|
||||
IsInstalled = TRUE;
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
return IsInstalled;
|
||||
}
|
||||
|
||||
BOOL
|
||||
InstalledVersion(LPWSTR szVersionResult, UINT iVersionResultSize, LPCWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow)
|
||||
{
|
||||
DWORD dwSize = MAX_PATH;
|
||||
DWORD dwType = REG_SZ;
|
||||
WCHAR szVersion[MAX_PATH];
|
||||
HKEY hKey, hSubKey;
|
||||
INT ItemIndex = 0;
|
||||
BOOL HasVersion = FALSE;
|
||||
iVersionResultSize = 0;
|
||||
|
||||
if (RegOpenKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, keyWow | KEY_ENUMERATE_SUB_KEYS,
|
||||
&hKey) != ERROR_SUCCESS)
|
||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, keyWow | KEY_ENUMERATE_SUB_KEYS,
|
||||
&hKey) == ERROR_SUCCESS)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while (RegEnumKeyExW(hKey, ItemIndex, szName, &dwSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
if (RegOpenKeyExW(hKey, szName, 0, keyWow | KEY_READ, &hSubKey) == ERROR_SUCCESS)
|
||||
if (FindRegistryKeyByName(hKey, keyWow, lpRegName, &hSubKey))
|
||||
{
|
||||
|
||||
dwType = REG_SZ;
|
||||
dwSize = sizeof(szDisplayName);
|
||||
dwSize = sizeof(szVersion);
|
||||
if (RegQueryValueExW(hSubKey,
|
||||
L"DisplayName",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE)szDisplayName,
|
||||
&dwSize) == ERROR_SUCCESS)
|
||||
L"DisplayVersion",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE) szVersion,
|
||||
&dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
if (wcscmp(szDisplayName, lpRegName) == 0)
|
||||
{
|
||||
RegCloseKey(hSubKey);
|
||||
RegCloseKey(hKey);
|
||||
return TRUE;
|
||||
}
|
||||
szVersionResult = szVersion;
|
||||
iVersionResultSize = dwSize;
|
||||
HasVersion = TRUE;
|
||||
}
|
||||
}
|
||||
RegCloseKey(hSubKey);
|
||||
dwSize = MAX_PATH;
|
||||
ItemIndex++;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return FALSE;
|
||||
return HasVersion;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -496,4 +496,28 @@ UINT ParserGetInt(LPCWSTR lpKeyName, LPCWSTR lpFileName)
|
|||
RtlUnicodeStringToInteger(&BufferW, 0, &Result);
|
||||
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
ParseVersion(LPWSTR szVersion, INT* version)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
//Finds subkey in key by name or path and returns it
|
||||
BOOL
|
||||
FindRegistryKeyByName(_In_ HKEY hKeyBase, _In_ REGSAM keyWow, _In_ LPCWSTR lpcKey, _Out_opt_ PHKEY hKeyResult)
|
||||
{
|
||||
HKEY hSubKey;
|
||||
if (RegOpenKeyExW(hKeyBase, lpcKey, 0, keyWow | KEY_READ, &hSubKey) == ERROR_SUCCESS)
|
||||
{
|
||||
hKeyResult = &hSubKey;
|
||||
return TRUE;
|
||||
}
|
||||
hKeyResult = NULL;
|
||||
RegCloseKey(hSubKey);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _RAPPS_H
|
||||
#define _RAPPS_H
|
||||
|
||||
|
@ -71,6 +73,7 @@
|
|||
#define IS_INSTALLED_ENUM(a) (a >= ENUM_INSTALLED_MIN && a <= ENUM_INSTALLED_MAX)
|
||||
#define IS_AVAILABLE_ENUM(a) (a >= ENUM_AVAILABLE_MIN && a <= ENUM_AVAILABLE_MAX)
|
||||
|
||||
|
||||
/* aboutdlg.c */
|
||||
VOID ShowAboutDialog(VOID);
|
||||
|
||||
|
@ -142,9 +145,11 @@ BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumP
|
|||
BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR lpString);
|
||||
BOOL ShowInstalledAppInfo(INT Index);
|
||||
BOOL UninstallApplication(INT Index, BOOL bModify);
|
||||
BOOL IsInstalledApplicationEx(LPWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow);
|
||||
BOOL IsInstalledApplication(LPCWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow);
|
||||
VOID RemoveAppFromRegistry(INT Index);
|
||||
|
||||
BOOL InstalledVersion(LPWSTR szVersionResult, UINT iVersionResultSize, LPCWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow);
|
||||
|
||||
/* winmain.c */
|
||||
extern HWND hMainWnd;
|
||||
extern HINSTANCE hInst;
|
||||
|
@ -176,6 +181,8 @@ BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPWSTR lpMsg);
|
|||
UINT ParserGetString(LPCWSTR lpKeyName, LPWSTR lpReturnedString, UINT nSize, LPCWSTR lpFileName);
|
||||
UINT ParserGetInt(LPCWSTR lpKeyName, LPCWSTR lpFileName);
|
||||
|
||||
BOOL FindRegistryKeyByName(_In_ HKEY hKeyBase, _In_ REGSAM keyWow, _In_ LPCWSTR lpcKey, _Out_opt_ PHKEY hKeyResult);
|
||||
|
||||
/* settingsdlg.c */
|
||||
VOID CreateSettingsDlg(HWND hwnd);
|
||||
|
||||
|
|
Loading…
Reference in a new issue