https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6f9dd96dcf89b7f40f271…
commit 6f9dd96dcf89b7f40f2717c30bce10c53ef95977
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Thu Sep 30 20:19:05 2021 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Oct 3 20:26:19 2021 +0200
[RAPPS] Cleanup
---
base/applications/rapps/include/misc.h | 12 +-------
base/applications/rapps/misc.cpp | 51 ++++------------------------------
base/applications/rapps/winmain.cpp | 47 ++++++-------------------------
3 files changed, 15 insertions(+), 95 deletions(-)
diff --git a/base/applications/rapps/include/misc.h
b/base/applications/rapps/include/misc.h
index 1a00feeb526..ff78d0a45bd 100644
--- a/base/applications/rapps/include/misc.h
+++ b/base/applications/rapps/include/misc.h
@@ -3,9 +3,6 @@
#include <windef.h>
#include <atlstr.h>
-#define EPOCH_DIFF 116444736000000000 //FILETIME starts from 1601-01-01 UTC, UnixTime
starts from 1970-01-01
-#define RATE_DIFF 10000000
-
#ifdef _M_IX86
#define CurrentArchitecture L"x86"
#elif defined(_M_AMD64)
@@ -20,16 +17,9 @@
#define CurrentArchitecture L"ppc"
#endif
-INT GetWindowWidth(HWND hwnd);
-INT GetWindowHeight(HWND hwnd);
-INT GetClientWindowWidth(HWND hwnd);
-INT GetClientWindowHeight(HWND hwnd);
-
VOID CopyTextToClipboard(LPCWSTR lpszText);
VOID ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem);
-VOID ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem);
-BOOL StartProcess(ATL::CStringW &Path, BOOL Wait);
-BOOL StartProcess(LPWSTR lpPath, BOOL Wait);
+BOOL StartProcess(const ATL::CStringW &Path, BOOL Wait);
BOOL GetStorageDirectory(ATL::CStringW &lpDirectory);
VOID InitLogs();
diff --git a/base/applications/rapps/misc.cpp b/base/applications/rapps/misc.cpp
index 0380705f4e3..742d4d67bb4 100644
--- a/base/applications/rapps/misc.cpp
+++ b/base/applications/rapps/misc.cpp
@@ -15,38 +15,6 @@ static HANDLE hLog = NULL;
static BOOL bIsSys64ResultCached = FALSE;
static BOOL bIsSys64Result = FALSE;
-INT GetWindowWidth(HWND hwnd)
-{
- RECT Rect;
-
- GetWindowRect(hwnd, &Rect);
- return (Rect.right - Rect.left);
-}
-
-INT GetWindowHeight(HWND hwnd)
-{
- RECT Rect;
-
- GetWindowRect(hwnd, &Rect);
- return (Rect.bottom - Rect.top);
-}
-
-INT GetClientWindowWidth(HWND hwnd)
-{
- RECT Rect;
-
- GetClientRect(hwnd, &Rect);
- return (Rect.right - Rect.left);
-}
-
-INT GetClientWindowHeight(HWND hwnd)
-{
- RECT Rect;
-
- GetClientRect(hwnd, &Rect);
- return (Rect.bottom - Rect.top);
-}
-
VOID CopyTextToClipboard(LPCWSTR lpszText)
{
if (!OpenClipboard(NULL))
@@ -112,18 +80,7 @@ VOID ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT
DefaultItem)
}
}
-VOID ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
-{
- ShowPopupMenuEx(hwnd, hMainWnd, MenuID, DefaultItem);
-}
-
-
-BOOL StartProcess(ATL::CStringW &Path, BOOL Wait)
-{
- return StartProcess(const_cast<LPWSTR>(Path.GetString()), Wait);;
-}
-
-BOOL StartProcess(LPWSTR lpPath, BOOL Wait)
+BOOL StartProcess(const ATL::CStringW& Path, BOOL Wait)
{
PROCESS_INFORMATION pi;
STARTUPINFOW si;
@@ -135,7 +92,11 @@ BOOL StartProcess(LPWSTR lpPath, BOOL Wait)
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
- if (!CreateProcessW(NULL, lpPath, NULL, NULL, FALSE, 0, NULL, NULL, &si,
&pi))
+ // The Unicode version of CreateProcess can modify the contents of this string.
+ CStringW Tmp = Path;
+ BOOL fSuccess = CreateProcessW(NULL, Tmp.GetBuffer(), NULL, NULL, FALSE, 0, NULL,
NULL, &si, &pi);
+ Tmp.ReleaseBuffer();
+ if (!fSuccess)
{
return FALSE;
}
diff --git a/base/applications/rapps/winmain.cpp b/base/applications/rapps/winmain.cpp
index 894bbb43f9c..cd2d82302b1 100644
--- a/base/applications/rapps/winmain.cpp
+++ b/base/applications/rapps/winmain.cpp
@@ -19,51 +19,20 @@ HWND hMainWnd;
HINSTANCE hInst;
SETTINGS_INFO SettingsInfo;
-class CRAppsModule : public CComModule
-{
-public:
-};
-
BEGIN_OBJECT_MAP(ObjectMap)
END_OBJECT_MAP()
-CRAppsModule gModule;
+CComModule gModule;
CAtlWinModule gWinModule;
-Gdiplus::GdiplusStartupInput gdiplusStartupInput;
-ULONG_PTR gdiplusToken;
-
-
-static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize)
-{
- if (bInitialize)
- {
- gModule.Init(ObjectMap, hInstance, NULL);
- }
- else
- {
- gModule.Term();
- }
-}
-
-VOID InitializeGDIPlus(BOOL bInitialize)
-{
- if (bInitialize)
- {
- Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
- }
- else
- {
- Gdiplus::GdiplusShutdown(gdiplusToken);
- }
-}
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, INT
nShowCmd)
{
- BOOL bIsFirstLaunch;
+ Gdiplus::GdiplusStartupInput gdiplusStartupInput;
+ ULONG_PTR gdiplusToken;
- InitializeAtlModule(hInstance, TRUE);
- InitializeGDIPlus(TRUE);
+ gModule.Init(ObjectMap, hInstance, NULL);
+ Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
if (GetUserDefaultUILanguage() == MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT))
{
@@ -72,7 +41,7 @@ INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR
lpCmdLi
hInst = hInstance;
- bIsFirstLaunch = !LoadSettings(&SettingsInfo);
+ BOOL bIsFirstLaunch = !LoadSettings(&SettingsInfo);
if (bIsFirstLaunch)
{
FillDefaultSettings(&SettingsInfo);
@@ -84,8 +53,8 @@ INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR
lpCmdLi
// parse cmd-line and perform the corresponding operation
BOOL bSuccess = ParseCmdAndExecute(GetCommandLineW(), bIsFirstLaunch,
SW_SHOWNORMAL);
- InitializeGDIPlus(FALSE);
- InitializeAtlModule(GetModuleHandle(NULL), FALSE);
+ Gdiplus::GdiplusShutdown(gdiplusToken);
+ gModule.Term();
return bSuccess ? 0 : 1;
}