Author: ashaposhnikov
Date: Wed Jul 12 22:59:26 2017
New Revision: 75324
URL:
http://svn.reactos.org/svn/reactos?rev=75324&view=rev
Log:
[RAPPS] More code improvements
- Replaced some functions with their Wide versions
- Generalized `GetInstalledVersion` function so it could accept NULL
- Minor cleanup
Modified:
branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/crichedit.h
branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/installed.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h
branches/GSoC_2017/rapps/reactos/base/applications/rapps/settingsdlg.cpp
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]
Wed Jul 12 22:59:26 2017
@@ -42,43 +42,30 @@
}
return TRUE;
}
-
-//App is "installed" if the RegName or Name is in the registry
-inline BOOL IsAppInstalledKey(PAPPLICATION_INFO Info, REGSAM key)
-{
- return (!Info->szRegName.IsEmpty()
- && (IsInstalledApplication(Info->szRegName, TRUE, key)
- || IsInstalledApplication(Info->szRegName, FALSE, key)))
- || (!Info->szName.IsEmpty()
- && (IsInstalledApplication(Info->szName, TRUE, key)
- || IsInstalledApplication(Info->szName, FALSE, key)));
-}
-
-
//Check both registry keys in 64bit system
//TODO: check system type beforehand to avoid double checks?
+
+inline BOOL GetInstalledVersionEx(PAPPLICATION_INFO Info, ATL::CStringW* szVersion,
REGSAM key)
+{
+ return (!Info->szRegName.IsEmpty()
+ && (GetInstalledVersion_WowUser(szVersion, Info->szRegName, TRUE,
key)
+ || GetInstalledVersion_WowUser(szVersion, Info->szRegName, FALSE,
key)))
+ || (!Info->szName.IsEmpty()
+ && (GetInstalledVersion_WowUser(szVersion, Info->szName, TRUE,
key)
+ || GetInstalledVersion_WowUser(szVersion, Info->szName, FALSE,
key)));
+}
+
+inline BOOL GetInstalledVersion(PAPPLICATION_INFO Info, ATL::CStringW* szVersion)
+{
+ return GetInstalledVersionEx(Info, szVersion, KEY_WOW64_32KEY)
+ || GetInstalledVersionEx(Info, szVersion, KEY_WOW64_64KEY);
+}
+
inline BOOL IsAppInstalled(PAPPLICATION_INFO Info)
{
- return IsAppInstalledKey(Info, KEY_WOW64_32KEY)
- || IsAppInstalledKey(Info, KEY_WOW64_64KEY);
-}
-
-//App is "installed" if the RegName or Name is in the registry
-inline BOOL GetInstalledVersionWithKey(PAPPLICATION_INFO Info, ATL::CStringW&
szVersion, REGSAM key)
-{
- return (!Info->szRegName.IsEmpty()
- && (InstalledVersion(szVersion, Info->szRegName, TRUE, key)
- || InstalledVersion(szVersion, Info->szRegName, FALSE, key)))
- || (!Info->szName.IsEmpty()
- && (InstalledVersion(szVersion, Info->szName, TRUE, key)
- || InstalledVersion(szVersion, Info->szName, FALSE, key)));
-}
-
-inline BOOL GetInstalledVersion(PAPPLICATION_INFO Info, ATL::CStringW& szVersion)
-{
- return GetInstalledVersionWithKey(Info, szVersion, KEY_WOW64_32KEY)
- || GetInstalledVersionWithKey(Info, szVersion, KEY_WOW64_64KEY);
-}
+ return GetInstalledVersion(Info, NULL);
+}
+
LIST_ENTRY CachedEntriesHead = {&CachedEntriesHead, &CachedEntriesHead};
PLIST_ENTRY pCachedEntry = &CachedEntriesHead;
@@ -90,7 +77,7 @@
ATL::CStringW szVersion;
ATL::CStringW szLicense;
BOOL bIsInstalled = IsAppInstalled(Info),
- bHasVersion = GetInstalledVersion(Info, szVersion);
+ bHasVersion = GetInstalledVersion(Info, &szVersion);
if (!Info) return FALSE;
@@ -221,7 +208,6 @@
ATL::CStringW szAppsPath;
ATL::CStringW szCabPath;
PAPPLICATION_INFO Info;
-
if (!GetStorageDirectory(szPath))
return FALSE;
@@ -301,7 +287,6 @@
InfoList.AddTail(Info);
skip_if_cached:
-
if (Info->Category == FALSE)
continue;
@@ -349,10 +334,8 @@
{
Info = InfoList.GetAt(InfoListPosition);
InfoList.RemoveHead();
-
- /* flush them down the toilet :D */
+ InfoListPosition = InfoList.GetHeadPosition();
+
delete Info;
-
- InfoListPosition = InfoList.GetHeadPosition();
}
}
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/crichedit.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/crichedit.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/crichedit.h [iso-8859-1] Wed
Jul 12 22:59:26 2017
@@ -22,7 +22,7 @@
public:
VOID SetRangeFormatting(LONG Start, LONG End, DWORD dwEffects)
{
- CHARFORMAT2 CharFormat;
+ CHARFORMAT2W CharFormat;
SendMessageW(EM_SETSEL, Start, End);
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1] Wed Jul
12 22:59:26 2017
@@ -37,12 +37,12 @@
{
HICON hImage;
- if (!(hImage = (HICON) LoadImage(hInst,
- MAKEINTRESOURCE(ImageIndex),
- IMAGE_ICON,
- TOOLBAR_HEIGHT,
- TOOLBAR_HEIGHT,
- 0)))
+ if (!(hImage = (HICON) LoadImageW(hInst,
+ MAKEINTRESOURCE(ImageIndex),
+ IMAGE_ICON,
+ TOOLBAR_HEIGHT,
+ TOOLBAR_HEIGHT,
+ 0)))
{
/* TODO: Error message */
}
@@ -266,7 +266,7 @@
INT CompareFunc(LPARAM lParam1, LPARAM lParam2, INT iSubItem)
{
ATL::CStringW Item1, Item2;
- LVFINDINFO IndexInfo;
+ LVFINDINFOW IndexInfo;
INT Index;
IndexInfo.flags = LVFI_PARAM;
@@ -366,7 +366,7 @@
public:
VOID SetText(LPCWSTR lpszText)
{
- SendMessage(SB_SETTEXT, SBT_NOBORDERS, (LPARAM) lpszText);
+ SendMessageW(SB_SETTEXT, SBT_NOBORDERS, (LPARAM) lpszText);
}
HWND Create(HWND hwndParent)
@@ -626,21 +626,31 @@
/* Size tool bar */
m_Toolbar->AutoSize();
-
RECT r = {0, 0, LOWORD(lParam), HIWORD(lParam)};
-
HDWP hdwp = NULL;
-
int count = m_ClientPanel->CountSizableChildren();
+
hdwp = BeginDeferWindowPos(count);
- if (hdwp) hdwp = m_ClientPanel->OnParentSize(r, hdwp);
- if (hdwp) EndDeferWindowPos(hdwp);
+ if (hdwp)
+ {
+ hdwp = m_ClientPanel->OnParentSize(r, hdwp);
+ }
+ if (hdwp)
+ {
+ EndDeferWindowPos(hdwp);
+ }
// TODO: Sub-layouts for children of children
count = m_SearchBar->CountSizableChildren();
hdwp = BeginDeferWindowPos(count);
- if (hdwp) hdwp = m_SearchBar->OnParentSize(r, hdwp);
- if (hdwp) EndDeferWindowPos(hdwp);
+ if (hdwp)
+ {
+ hdwp = m_SearchBar->OnParentSize(r, hdwp);
+ }
+ if (hdwp)
+ {
+ EndDeferWindowPos(hdwp);
+ }
}
BOOL ProcessWindowMessage(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam,
LRESULT& theResult, DWORD dwMapId)
@@ -781,10 +791,10 @@
EnableMenuItem(lvwMenu, ID_UNINSTALL, MF_ENABLED);
EnableMenuItem(lvwMenu, ID_MODIFY, MF_ENABLED);
- m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_REGREMOVE, TRUE);
- m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_INSTALL, FALSE);
- m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_UNINSTALL, TRUE);
- m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_MODIFY, TRUE);
+ m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_REGREMOVE, TRUE);
+ m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_INSTALL, FALSE);
+ m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_UNINSTALL, TRUE);
+ m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_MODIFY, TRUE);
}
else
{
@@ -798,10 +808,10 @@
EnableMenuItem(lvwMenu, ID_UNINSTALL, MF_GRAYED);
EnableMenuItem(lvwMenu, ID_MODIFY, MF_GRAYED);
- m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_REGREMOVE, FALSE);
- m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_INSTALL, TRUE);
- m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_UNINSTALL, FALSE);
- m_Toolbar->SendMessage(TB_ENABLEBUTTON, ID_MODIFY, FALSE);
+ m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_REGREMOVE, FALSE);
+ m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_INSTALL, TRUE);
+ m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_UNINSTALL, FALSE);
+ m_Toolbar->SendMessageW(TB_ENABLEBUTTON, ID_MODIFY, FALSE);
}
}
break;
@@ -905,10 +915,10 @@
case WM_SYSCOLORCHANGE:
{
/* Forward WM_SYSCOLORCHANGE to common controls */
- m_ListView->SendMessage(WM_SYSCOLORCHANGE, 0, 0);
- m_TreeView->SendMessage(WM_SYSCOLORCHANGE, 0, 0);
- m_Toolbar->SendMessage(WM_SYSCOLORCHANGE, 0, 0);
- m_ListView->SendMessage(EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_BTNFACE));
+ m_ListView->SendMessageW(WM_SYSCOLORCHANGE, 0, 0);
+ m_TreeView->SendMessageW(WM_SYSCOLORCHANGE, 0, 0);
+ m_Toolbar->SendMessageW(WM_SYSCOLORCHANGE, 0, 0);
+ m_ListView->SendMessageW(EM_SETBKGNDCOLOR, 0,
GetSysColor(COLOR_BTNFACE));
}
break;
@@ -1028,7 +1038,7 @@
}
DWORD dwDelay;
- SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &dwDelay, 0);
+ SystemParametersInfoW(SPI_GETMENUSHOWDELAY, 0, &dwDelay, 0);
SetTimer(SEARCH_TIMER_ID, dwDelay);
}
break;
@@ -1186,7 +1196,7 @@
if (!hIcon)
{
/* Load default icon */
- hIcon = (HICON) LoadIcon(hInst, MAKEINTRESOURCEW(IDI_MAIN));
+ hIcon = (HICON) LoadIconW(hInst, MAKEINTRESOURCEW(IDI_MAIN));
}
Index = ImageList_AddIcon(hImageListView, hIcon);
DestroyIcon(hIcon);
@@ -1208,7 +1218,7 @@
ATL::CStringW szBuffer1, szBuffer2;
HIMAGELIST hImageListView = NULL;
- m_ListView->SendMessage(WM_SETREDRAW, FALSE, 0);
+ m_ListView->SendMessageW(WM_SETREDRAW, FALSE, 0);
if (EnumType < 0) EnumType = SelectedEnumType;
@@ -1244,7 +1254,7 @@
if (ListView_GetItemCount(hListView) > 0)
ListView_SetColumnWidth(hListView, 0, LVSCW_AUTOSIZE);
- SendMessage(hListView, WM_SETREDRAW, TRUE, 0);
+ SendMessageW(hListView, WM_SETREDRAW, TRUE, 0);
}
public:
@@ -1253,12 +1263,20 @@
DWORD csStyle = CS_VREDRAW | CS_HREDRAW;
static ATL::CWndClassInfo wc =
{
- { sizeof(WNDCLASSEX), csStyle, StartWindowProc,
- 0, 0, NULL,
- LoadIcon(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDI_MAIN)),
- LoadCursor(NULL, IDC_ARROW),
- (HBRUSH) (COLOR_BTNFACE + 1), MAKEINTRESOURCE(IDR_MAINMENU),
- L"RAppsWnd", NULL },
+ {
+ sizeof(WNDCLASSEX),
+ csStyle,
+ StartWindowProc,
+ 0,
+ 0,
+ NULL,
+ LoadIconW(_AtlBaseModule.GetModuleInstance(),
MAKEINTRESOURCEW(IDI_MAIN)),
+ LoadCursorW(NULL, IDC_ARROW),
+ (HBRUSH) (COLOR_BTNFACE + 1),
+ MAKEINTRESOURCEW(IDR_MAINMENU),
+ L"RAppsWnd",
+ NULL
+ },
NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
};
return wc;
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]
Wed Jul 12 22:59:26 2017
@@ -37,27 +37,10 @@
}
BOOL
-IsInstalledApplication(const ATL::CStringW &RegName, BOOL IsUserKey, REGSAM keyWow)
-{
- HKEY hKey = NULL;
- BOOL IsInstalled = FALSE;
- ATL::CStringW szPath =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegName;
-
- if (RegOpenKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
- szPath, 0, keyWow | KEY_READ,
- &hKey) == ERROR_SUCCESS)
- {
- IsInstalled = TRUE;
- }
- RegCloseKey(hKey);
- return IsInstalled;
-}
-
-BOOL
-InstalledVersion(ATL::CStringW& szVersionResult, const ATL::CStringW& RegName,
BOOL IsUserKey, REGSAM keyWow)
+GetInstalledVersion_WowUser(_Out_opt_ ATL::CStringW* szVersionResult, _In_z_ const
ATL::CStringW& RegName, _In_ BOOL IsUserKey, _In_ REGSAM keyWow)
{
HKEY hKey;
- BOOL bHasVersion = FALSE;
+ BOOL bHasSucceded = FALSE;
ATL::CStringW szVersion;
ATL::CStringW szPath =
L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegName;
@@ -65,27 +48,36 @@
szPath.GetString(), 0, keyWow | KEY_READ,
&hKey) == ERROR_SUCCESS)
{
- DWORD dwSize = MAX_PATH * sizeof(WCHAR);
- DWORD dwType = REG_SZ;
- if (RegQueryValueExW(hKey,
- L"DisplayVersion",
- NULL,
- &dwType,
- (LPBYTE) szVersion.GetBuffer(MAX_PATH),
- &dwSize) == ERROR_SUCCESS)
+ if (szVersionResult)
{
- szVersion.ReleaseBuffer();
- szVersionResult = szVersion;
- bHasVersion = TRUE;
+ DWORD dwSize = MAX_PATH * sizeof(WCHAR);
+ DWORD dwType = REG_SZ;
+ if (RegQueryValueExW(hKey,
+ L"DisplayVersion",
+ NULL,
+ &dwType,
+ (LPBYTE) szVersion.GetBuffer(MAX_PATH),
+ &dwSize) == ERROR_SUCCESS)
+ {
+ szVersion.ReleaseBuffer();
+ *szVersionResult = szVersion;
+ bHasSucceded = TRUE;
+ }
+ else
+ {
+ szVersion.ReleaseBuffer();
+ }
}
else
{
+ bHasSucceded = TRUE;
szVersion.ReleaseBuffer();
}
+
}
RegCloseKey(hKey);
- return bHasVersion;
+ return bHasSucceded;
}
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] Wed Jul
12 22:59:26 2017
@@ -159,10 +159,9 @@
BOOL ShowInstalledAppInfo(INT Index);
BOOL UninstallApplication(INT Index, BOOL bModify);
-BOOL IsInstalledApplication(const ATL::CStringW& RegName, BOOL IsUserKey, REGSAM
keyWow);
VOID RemoveAppFromRegistry(INT Index);
-BOOL InstalledVersion(ATL::CStringW& szVersionResult, const ATL::CStringW&
RegName, BOOL IsUserKey, REGSAM keyWow);
+BOOL GetInstalledVersion_WowUser(ATL::CStringW* szVersionResult, const ATL::CStringW&
RegName, BOOL IsUserKey, REGSAM keyWow);
/* winmain.cpp */
extern HWND hMainWnd;
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/settingsdlg.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/settingsdlg.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/settingsdlg.cpp [iso-8859-1]
Wed Jul 12 22:59:26 2017
@@ -12,7 +12,7 @@
SETTINGS_INFO NewSettingsInfo;
#define IS_CHECKED(a, b) \
- a = (SendDlgItemMessage(hDlg, b, BM_GETCHECK, 0, 0) == BST_CHECKED) ? TRUE : FALSE
+ a = (SendDlgItemMessageW(hDlg, b, BM_GETCHECK, 0, 0) == BST_CHECKED) ? TRUE : FALSE
BOOL
ChooseFolder(HWND hwnd)
@@ -32,13 +32,13 @@
szBuf.Empty();
if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)))
{
- LPITEMIDLIST lpItemList = SHBrowseForFolder(&bi);
- if (lpItemList && SHGetPathFromIDList(lpItemList,
szBuf.GetBuffer(MAX_PATH)))
+ LPITEMIDLIST lpItemList = SHBrowseForFolderW(&bi);
+ if (lpItemList && SHGetPathFromIDListW(lpItemList,
szBuf.GetBuffer(MAX_PATH)))
{
szBuf.ReleaseBuffer();
if (!szBuf.IsEmpty())
{
- SetDlgItemTextW(hwnd, IDC_DOWNLOAD_DIR_EDIT, szBuf.GetString());
+ SetDlgItemTextW(hwnd, IDC_DOWNLOAD_DIR_EDIT, szBuf);
bRet = TRUE;
}
}
@@ -55,10 +55,10 @@
static VOID
InitSettingsControls(HWND hDlg, PSETTINGS_INFO Info)
{
- SendDlgItemMessage(hDlg, IDC_SAVE_WINDOW_POS, BM_SETCHECK, Info->bSaveWndPos, 0);
- SendDlgItemMessage(hDlg, IDC_UPDATE_AVLIST, BM_SETCHECK, Info->bUpdateAtStart,
0);
- SendDlgItemMessage(hDlg, IDC_LOG_ENABLED, BM_SETCHECK, Info->bLogEnabled, 0);
- SendDlgItemMessage(hDlg, IDC_DEL_AFTER_INSTALL, BM_SETCHECK, Info->bDelInstaller,
0);
+ SendDlgItemMessageW(hDlg, IDC_SAVE_WINDOW_POS, BM_SETCHECK, Info->bSaveWndPos,
0);
+ SendDlgItemMessageW(hDlg, IDC_UPDATE_AVLIST, BM_SETCHECK, Info->bUpdateAtStart,
0);
+ SendDlgItemMessageW(hDlg, IDC_LOG_ENABLED, BM_SETCHECK, Info->bLogEnabled, 0);
+ SendDlgItemMessageW(hDlg, IDC_DEL_AFTER_INSTALL, BM_SETCHECK, Info->bDelInstaller,
0);
SetWindowTextW(GetDlgItem(hDlg, IDC_DOWNLOAD_DIR_EDIT),
Info->szDownloadDir);