mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 20:34:59 +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
|
//App is "installed" if the RegName or Name is in the registry
|
||||||
inline bool _AppInstallCheckKey(PAPPLICATION_INFO Info, REGSAM key) {
|
inline bool _AppInstallCheckKey(PAPPLICATION_INFO Info, REGSAM key)
|
||||||
return *Info->szRegName
|
{
|
||||||
&& (IsInstalledApplicationEx(Info->szRegName, TRUE, key)
|
return (*Info->szRegName
|
||||||
|| IsInstalledApplicationEx(Info->szRegName, FALSE, key));
|
&& (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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
BOOL
|
||||||
IsInstalledApplicationEx(LPWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow)
|
IsInstalledApplication(LPCWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow)
|
||||||
{
|
{
|
||||||
DWORD dwSize = MAX_PATH, dwType;
|
HKEY hKey = NULL;
|
||||||
WCHAR szName[MAX_PATH];
|
BOOL IsInstalled = FALSE;
|
||||||
WCHAR szDisplayName[MAX_PATH];
|
|
||||||
|
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;
|
HKEY hKey, hSubKey;
|
||||||
INT ItemIndex = 0;
|
BOOL HasVersion = FALSE;
|
||||||
|
iVersionResultSize = 0;
|
||||||
|
|
||||||
if (RegOpenKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
if (RegOpenKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
||||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, keyWow | KEY_ENUMERATE_SUB_KEYS,
|
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, keyWow | KEY_ENUMERATE_SUB_KEYS,
|
||||||
&hKey) != ERROR_SUCCESS)
|
&hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
return FALSE;
|
if (FindRegistryKeyByName(hKey, keyWow, lpRegName, &hSubKey))
|
||||||
}
|
|
||||||
|
|
||||||
while (RegEnumKeyExW(hKey, ItemIndex, szName, &dwSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
if (RegOpenKeyExW(hKey, szName, 0, keyWow | KEY_READ, &hSubKey) == ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
|
dwSize = sizeof(szVersion);
|
||||||
dwType = REG_SZ;
|
|
||||||
dwSize = sizeof(szDisplayName);
|
|
||||||
if (RegQueryValueExW(hSubKey,
|
if (RegQueryValueExW(hSubKey,
|
||||||
L"DisplayName",
|
L"DisplayVersion",
|
||||||
NULL,
|
NULL,
|
||||||
&dwType,
|
&dwType,
|
||||||
(LPBYTE)szDisplayName,
|
(LPBYTE) szVersion,
|
||||||
&dwSize) == ERROR_SUCCESS)
|
&dwSize) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (wcscmp(szDisplayName, lpRegName) == 0)
|
szVersionResult = szVersion;
|
||||||
{
|
iVersionResultSize = dwSize;
|
||||||
RegCloseKey(hSubKey);
|
HasVersion = TRUE;
|
||||||
RegCloseKey(hKey);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RegCloseKey(hSubKey);
|
RegCloseKey(hSubKey);
|
||||||
dwSize = MAX_PATH;
|
|
||||||
ItemIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
return FALSE;
|
return HasVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -496,4 +496,28 @@ UINT ParserGetInt(LPCWSTR lpKeyName, LPCWSTR lpFileName)
|
||||||
RtlUnicodeStringToInteger(&BufferW, 0, &Result);
|
RtlUnicodeStringToInteger(&BufferW, 0, &Result);
|
||||||
|
|
||||||
return 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
|
#ifndef _RAPPS_H
|
||||||
#define _RAPPS_H
|
#define _RAPPS_H
|
||||||
|
|
||||||
|
@ -71,6 +73,7 @@
|
||||||
#define IS_INSTALLED_ENUM(a) (a >= ENUM_INSTALLED_MIN && a <= ENUM_INSTALLED_MAX)
|
#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)
|
#define IS_AVAILABLE_ENUM(a) (a >= ENUM_AVAILABLE_MIN && a <= ENUM_AVAILABLE_MAX)
|
||||||
|
|
||||||
|
|
||||||
/* aboutdlg.c */
|
/* aboutdlg.c */
|
||||||
VOID ShowAboutDialog(VOID);
|
VOID ShowAboutDialog(VOID);
|
||||||
|
|
||||||
|
@ -142,9 +145,11 @@ BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumP
|
||||||
BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR lpString);
|
BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR lpString);
|
||||||
BOOL ShowInstalledAppInfo(INT Index);
|
BOOL ShowInstalledAppInfo(INT Index);
|
||||||
BOOL UninstallApplication(INT Index, BOOL bModify);
|
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);
|
VOID RemoveAppFromRegistry(INT Index);
|
||||||
|
|
||||||
|
BOOL InstalledVersion(LPWSTR szVersionResult, UINT iVersionResultSize, LPCWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow);
|
||||||
|
|
||||||
/* winmain.c */
|
/* winmain.c */
|
||||||
extern HWND hMainWnd;
|
extern HWND hMainWnd;
|
||||||
extern HINSTANCE hInst;
|
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 ParserGetString(LPCWSTR lpKeyName, LPWSTR lpReturnedString, UINT nSize, LPCWSTR lpFileName);
|
||||||
UINT ParserGetInt(LPCWSTR lpKeyName, 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 */
|
/* settingsdlg.c */
|
||||||
VOID CreateSettingsDlg(HWND hwnd);
|
VOID CreateSettingsDlg(HWND hwnd);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue