Author: ashaposhnikov
Date: Mon Jun 26 22:07:43 2017
New Revision: 75211
URL:
http://svn.reactos.org/svn/reactos?rev=75211&view=rev
Log:
[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
Modified:
branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
Mon Jun 26 22:07:43 2017
@@ -40,11 +40,14 @@
}
}
-//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)));
}
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp [iso-8859-1]
Mon Jun 26 22:07:43 2017
@@ -28,50 +28,59 @@
return FALSE;
}
-BOOL
-IsInstalledApplicationEx(LPWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow)
-{
- DWORD dwSize = MAX_PATH, dwType;
- WCHAR szName[MAX_PATH];
- WCHAR szDisplayName[MAX_PATH];
+
+
+BOOL
+IsInstalledApplication(LPCWSTR lpRegName, BOOL IsUserKey, REGSAM keyWow)
+{
+ 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)
- {
- 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)
+ L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall", 0, keyWow |
KEY_ENUMERATE_SUB_KEYS,
+ &hKey) == 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)
- {
- if (wcscmp(szDisplayName, lpRegName) == 0)
- {
- RegCloseKey(hSubKey);
- RegCloseKey(hKey);
- return TRUE;
- }
+ L"DisplayVersion",
+ NULL,
+ &dwType,
+ (LPBYTE) szVersion,
+ &dwSize) == ERROR_SUCCESS)
+ {
+ szVersionResult = szVersion;
+ iVersionResultSize = dwSize;
+ HasVersion = TRUE;
}
}
RegCloseKey(hSubKey);
- dwSize = MAX_PATH;
- ItemIndex++;
- }
+ }
+
RegCloseKey(hKey);
- return FALSE;
+ return HasVersion;
}
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/misc.cpp [iso-8859-1] Mon Jun
26 22:07:43 2017
@@ -496,4 +496,28 @@
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;
+}
+
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h [iso-8859-1] Mon Jun
26 22:07:43 2017
@@ -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,8 +145,10 @@
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;
@@ -176,6 +181,8 @@
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);