mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 23:05:41 +00:00
[RAPPS]
- Refactoring - A template for a future parameters parser svn path=/branches/GSoC_2017/rapps/; revision=75512
This commit is contained in:
parent
284762155e
commit
9293dbee23
6 changed files with 190 additions and 221 deletions
|
@ -4,32 +4,21 @@
|
||||||
* FILE: base/applications/rapps/aboutdlg.cpp
|
* FILE: base/applications/rapps/aboutdlg.cpp
|
||||||
* PURPOSE: About Dialog
|
* PURPOSE: About Dialog
|
||||||
* PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
|
* PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
|
||||||
|
* Alexander Shaposhikov (chaez.san@gmail.com)
|
||||||
*/
|
*/
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
static
|
static INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
INT_PTR CALLBACK
|
|
||||||
AboutDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
switch (Msg)
|
if (Msg == WM_COMMAND && LOWORD(wParam) == IDOK)
|
||||||
{
|
{
|
||||||
case WM_COMMAND:
|
return EndDialog(hDlg, LOWORD(wParam));
|
||||||
{
|
|
||||||
switch (LOWORD(wParam))
|
|
||||||
{
|
|
||||||
case IDOK:
|
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID ShowAboutDialog()
|
||||||
ShowAboutDialog(VOID)
|
|
||||||
{
|
{
|
||||||
DialogBoxW(hInst,
|
DialogBoxW(hInst,
|
||||||
MAKEINTRESOURCEW(IDD_ABOUT_DIALOG),
|
MAKEINTRESOURCEW(IDD_ABOUT_DIALOG),
|
||||||
|
|
|
@ -288,7 +288,10 @@ BOOL CAvailableApps::EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnu
|
||||||
if (hFind == INVALID_HANDLE_VALUE)
|
if (hFind == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
if (GetFileAttributesW(m_szCabPath) == INVALID_FILE_ATTRIBUTES)
|
if (GetFileAttributesW(m_szCabPath) == INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
CDownloadManager::DownloadApplicationsDB(APPLICATION_DATABASE_URL);
|
CDownloadManager::DownloadApplicationsDB(APPLICATION_DATABASE_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ExtractFilesFromCab(m_szCabPath, m_szAppsPath);
|
ExtractFilesFromCab(m_szCabPath, m_szAppsPath);
|
||||||
hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData);
|
hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData);
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include "rosui.h"
|
#include "rosui.h"
|
||||||
#include "dialogs.h"
|
#include "dialogs.h"
|
||||||
|
#include "misc.h"
|
||||||
|
|
||||||
#ifdef USE_CERT_PINNING
|
#ifdef USE_CERT_PINNING
|
||||||
#define CERT_ISSUER_INFO "BE\r\nGlobalSign nv-sa\r\nGlobalSign Domain Validation CA - SHA256 - G2"
|
#define CERT_ISSUER_INFO "BE\r\nGlobalSign nv-sa\r\nGlobalSign Domain Validation CA - SHA256 - G2"
|
||||||
|
@ -336,8 +337,7 @@ static BOOL CertIsValid(HINTERNET hInternet, LPWSTR lpszHostName)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline VOID
|
inline VOID MessageBox_LoadString(HWND hMainWnd, INT StringID)
|
||||||
MessageBox_LoadString(HWND hMainWnd, INT StringID)
|
|
||||||
{
|
{
|
||||||
ATL::CString szMsgText;
|
ATL::CString szMsgText;
|
||||||
if (szMsgText.LoadStringW(hInst, StringID))
|
if (szMsgText.LoadStringW(hInst, StringID))
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
|
|
||||||
static HANDLE hLog = NULL;
|
static HANDLE hLog = NULL;
|
||||||
|
|
||||||
typedef struct
|
struct ERF
|
||||||
{
|
{
|
||||||
int erfOper;
|
int erfOper;
|
||||||
int erfType;
|
int erfType;
|
||||||
BOOL fError;
|
BOOL fError;
|
||||||
} ERF, *PERF;
|
};
|
||||||
|
|
||||||
struct FILELIST
|
struct FILELIST
|
||||||
{
|
{
|
||||||
|
@ -48,9 +48,7 @@ struct SESSION
|
||||||
typedef HRESULT(WINAPI *fnExtract)(SESSION *dest, LPCSTR szCabName);
|
typedef HRESULT(WINAPI *fnExtract)(SESSION *dest, LPCSTR szCabName);
|
||||||
fnExtract pfnExtract;
|
fnExtract pfnExtract;
|
||||||
|
|
||||||
|
INT GetWindowWidth(HWND hwnd)
|
||||||
int
|
|
||||||
GetWindowWidth(HWND hwnd)
|
|
||||||
{
|
{
|
||||||
RECT Rect;
|
RECT Rect;
|
||||||
|
|
||||||
|
@ -58,8 +56,7 @@ GetWindowWidth(HWND hwnd)
|
||||||
return (Rect.right - Rect.left);
|
return (Rect.right - Rect.left);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
INT GetWindowHeight(HWND hwnd)
|
||||||
GetWindowHeight(HWND hwnd)
|
|
||||||
{
|
{
|
||||||
RECT Rect;
|
RECT Rect;
|
||||||
|
|
||||||
|
@ -67,8 +64,7 @@ GetWindowHeight(HWND hwnd)
|
||||||
return (Rect.bottom - Rect.top);
|
return (Rect.bottom - Rect.top);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
INT GetClientWindowWidth(HWND hwnd)
|
||||||
GetClientWindowWidth(HWND hwnd)
|
|
||||||
{
|
{
|
||||||
RECT Rect;
|
RECT Rect;
|
||||||
|
|
||||||
|
@ -76,8 +72,7 @@ GetClientWindowWidth(HWND hwnd)
|
||||||
return (Rect.right - Rect.left);
|
return (Rect.right - Rect.left);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
INT GetClientWindowHeight(HWND hwnd)
|
||||||
GetClientWindowHeight(HWND hwnd)
|
|
||||||
{
|
{
|
||||||
RECT Rect;
|
RECT Rect;
|
||||||
|
|
||||||
|
@ -85,33 +80,33 @@ GetClientWindowHeight(HWND hwnd)
|
||||||
return (Rect.bottom - Rect.top);
|
return (Rect.bottom - Rect.top);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID CopyTextToClipboard(LPCWSTR lpszText)
|
||||||
CopyTextToClipboard(LPCWSTR lpszText)
|
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
if (!OpenClipboard(NULL))
|
||||||
|
|
||||||
if (OpenClipboard(NULL))
|
|
||||||
{
|
{
|
||||||
HGLOBAL ClipBuffer;
|
return;
|
||||||
WCHAR *Buffer;
|
|
||||||
DWORD cchBuffer;
|
|
||||||
|
|
||||||
EmptyClipboard();
|
|
||||||
cchBuffer = wcslen(lpszText) + 1;
|
|
||||||
ClipBuffer = GlobalAlloc(GMEM_DDESHARE, cchBuffer * sizeof(WCHAR));
|
|
||||||
Buffer = (PWCHAR) GlobalLock(ClipBuffer);
|
|
||||||
hr = StringCchCopyW(Buffer, cchBuffer, lpszText);
|
|
||||||
GlobalUnlock(ClipBuffer);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
|
||||||
SetClipboardData(CF_UNICODETEXT, ClipBuffer);
|
|
||||||
|
|
||||||
CloseClipboard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT hr;
|
||||||
|
HGLOBAL ClipBuffer;
|
||||||
|
LPWSTR Buffer;
|
||||||
|
DWORD cchBuffer;
|
||||||
|
|
||||||
|
EmptyClipboard();
|
||||||
|
cchBuffer = wcslen(lpszText) + 1;
|
||||||
|
ClipBuffer = GlobalAlloc(GMEM_DDESHARE, cchBuffer * sizeof(WCHAR));
|
||||||
|
|
||||||
|
Buffer = (PWCHAR) GlobalLock(ClipBuffer);
|
||||||
|
hr = StringCchCopyW(Buffer, cchBuffer, lpszText);
|
||||||
|
GlobalUnlock(ClipBuffer);
|
||||||
|
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
SetClipboardData(CF_UNICODETEXT, ClipBuffer);
|
||||||
|
|
||||||
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID SetWelcomeText()
|
||||||
SetWelcomeText(VOID)
|
|
||||||
{
|
{
|
||||||
ATL::CStringW szText;
|
ATL::CStringW szText;
|
||||||
|
|
||||||
|
@ -125,12 +120,11 @@ SetWelcomeText(VOID)
|
||||||
InsertRichEditText(szText, CFM_LINK);
|
InsertRichEditText(szText, CFM_LINK);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
|
||||||
ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
|
|
||||||
{
|
{
|
||||||
HMENU hMenu = NULL;
|
HMENU hMenu = NULL;
|
||||||
HMENU hPopupMenu;
|
HMENU hPopupMenu;
|
||||||
MENUITEMINFO mii;
|
MENUITEMINFO ItemInfo;
|
||||||
POINT pt;
|
POINT pt;
|
||||||
|
|
||||||
if (MenuID)
|
if (MenuID)
|
||||||
|
@ -139,15 +133,20 @@ ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
|
||||||
hPopupMenu = GetSubMenu(hMenu, 0);
|
hPopupMenu = GetSubMenu(hMenu, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
hPopupMenu = GetMenu(hwnd);
|
hPopupMenu = GetMenu(hwnd);
|
||||||
|
}
|
||||||
|
|
||||||
ZeroMemory(&mii, sizeof(mii));
|
ZeroMemory(&ItemInfo, sizeof(ItemInfo));
|
||||||
mii.cbSize = sizeof(mii);
|
ItemInfo.cbSize = sizeof(ItemInfo);
|
||||||
mii.fMask = MIIM_STATE;
|
ItemInfo.fMask = MIIM_STATE;
|
||||||
GetMenuItemInfoW(hPopupMenu, DefaultItem, FALSE, &mii);
|
|
||||||
|
|
||||||
if (!(mii.fState & MFS_GRAYED))
|
GetMenuItemInfoW(hPopupMenu, DefaultItem, FALSE, &ItemInfo);
|
||||||
|
|
||||||
|
if (!(ItemInfo.fState & MFS_GRAYED))
|
||||||
|
{
|
||||||
SetMenuDefaultItem(hPopupMenu, DefaultItem, FALSE);
|
SetMenuDefaultItem(hPopupMenu, DefaultItem, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
GetCursorPos(&pt);
|
GetCursorPos(&pt);
|
||||||
|
|
||||||
|
@ -155,18 +154,17 @@ ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
|
||||||
TrackPopupMenu(hPopupMenu, 0, pt.x, pt.y, 0, hMainWnd, NULL);
|
TrackPopupMenu(hPopupMenu, 0, pt.x, pt.y, 0, hMainWnd, NULL);
|
||||||
|
|
||||||
if (hMenu)
|
if (hMenu)
|
||||||
|
{
|
||||||
DestroyMenu(hMenu);
|
DestroyMenu(hMenu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL StartProcess(ATL::CStringW &Path, BOOL Wait)
|
||||||
StartProcess(ATL::CStringW &Path, BOOL Wait)
|
{
|
||||||
{
|
return StartProcess(const_cast<LPWSTR>(Path.GetString()), Wait);;
|
||||||
BOOL result = StartProcess(const_cast<LPWSTR>(Path.GetString()), Wait);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL StartProcess(LPWSTR lpPath, BOOL Wait)
|
||||||
StartProcess(LPWSTR lpPath, BOOL Wait)
|
|
||||||
{
|
{
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
STARTUPINFOW si;
|
STARTUPINFOW si;
|
||||||
|
@ -184,7 +182,11 @@ StartProcess(LPWSTR lpPath, BOOL Wait)
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(pi.hThread);
|
CloseHandle(pi.hThread);
|
||||||
if (Wait) EnableWindow(hMainWnd, FALSE);
|
|
||||||
|
if (Wait)
|
||||||
|
{
|
||||||
|
EnableWindow(hMainWnd, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
while (Wait)
|
while (Wait)
|
||||||
{
|
{
|
||||||
|
@ -194,7 +196,7 @@ StartProcess(LPWSTR lpPath, BOOL Wait)
|
||||||
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessageW(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -216,8 +218,7 @@ StartProcess(LPWSTR lpPath, BOOL Wait)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL GetStorageDirectory(ATL::CStringW& Directory)
|
||||||
GetStorageDirectory(ATL::CStringW& Directory)
|
|
||||||
{
|
{
|
||||||
if (!SHGetSpecialFolderPathW(NULL, Directory.GetBuffer(MAX_PATH), CSIDL_LOCAL_APPDATA, TRUE))
|
if (!SHGetSpecialFolderPathW(NULL, Directory.GetBuffer(MAX_PATH), CSIDL_LOCAL_APPDATA, TRUE))
|
||||||
{
|
{
|
||||||
|
@ -231,14 +232,12 @@ GetStorageDirectory(ATL::CStringW& Directory)
|
||||||
return (CreateDirectoryW(Directory.GetString(), NULL) || GetLastError() == ERROR_ALREADY_EXISTS);
|
return (CreateDirectoryW(Directory.GetString(), NULL) || GetLastError() == ERROR_ALREADY_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL ExtractFilesFromCab(const ATL::CStringW &CabName, const ATL::CStringW &OutputPath)
|
||||||
ExtractFilesFromCab(const ATL::CStringW &CabName, const ATL::CStringW &OutputPath)
|
|
||||||
{
|
{
|
||||||
return ExtractFilesFromCab(CabName.GetString(), OutputPath.GetString());
|
return ExtractFilesFromCab(CabName.GetString(), OutputPath.GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL ExtractFilesFromCab(LPCWSTR lpCabName, LPCWSTR lpOutputPath)
|
||||||
ExtractFilesFromCab(LPCWSTR lpCabName, LPCWSTR lpOutputPath)
|
|
||||||
{
|
{
|
||||||
HINSTANCE hCabinetDll;
|
HINSTANCE hCabinetDll;
|
||||||
CHAR szCabName[MAX_PATH];
|
CHAR szCabName[MAX_PATH];
|
||||||
|
@ -275,92 +274,67 @@ ExtractFilesFromCab(LPCWSTR lpCabName, LPCWSTR lpOutputPath)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID InitLogs()
|
||||||
InitLogs(VOID)
|
|
||||||
{
|
{
|
||||||
WCHAR szBuf[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\ReactOS Application Manager";
|
if (!SettingsInfo.bLogEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WCHAR szPath[MAX_PATH];
|
WCHAR szPath[MAX_PATH];
|
||||||
DWORD dwCategoryNum = 1;
|
DWORD dwCategoryNum = 1;
|
||||||
DWORD dwDisp, dwData;
|
DWORD dwDisp, dwData;
|
||||||
HKEY hKey;
|
ATL::CRegKey key;
|
||||||
|
|
||||||
if (!SettingsInfo.bLogEnabled) return;
|
if (key.Create(HKEY_LOCAL_MACHINE,
|
||||||
|
L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\ReactOS Application Manager",
|
||||||
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,
|
REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &dwDisp) != ERROR_SUCCESS)
|
||||||
szBuf, 0, NULL,
|
|
||||||
REG_OPTION_NON_VOLATILE,
|
|
||||||
KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GetModuleFileNameW(NULL, szPath, _countof(szPath)))
|
if (!GetModuleFileNameW(NULL, szPath, _countof(szPath)))
|
||||||
return;
|
|
||||||
|
|
||||||
if (RegSetValueExW(hKey,
|
|
||||||
L"EventMessageFile",
|
|
||||||
0,
|
|
||||||
REG_EXPAND_SZ,
|
|
||||||
(LPBYTE) szPath,
|
|
||||||
(DWORD) (wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
RegCloseKey(hKey);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
|
dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
|
||||||
EVENTLOG_INFORMATION_TYPE;
|
EVENTLOG_INFORMATION_TYPE;
|
||||||
|
|
||||||
if (RegSetValueExW(hKey,
|
if ((key.SetStringValue(L"EventMessageFile",
|
||||||
L"TypesSupported",
|
szPath,
|
||||||
0,
|
REG_EXPAND_SZ) == ERROR_SUCCESS)
|
||||||
REG_DWORD,
|
&& (key.SetStringValue(L"CategoryMessageFile",
|
||||||
(LPBYTE) &dwData,
|
szPath,
|
||||||
sizeof(DWORD)) != ERROR_SUCCESS)
|
REG_EXPAND_SZ) == ERROR_SUCCESS)
|
||||||
|
&& (key.SetDWORDValue(L"TypesSupported",
|
||||||
|
dwData) == ERROR_SUCCESS)
|
||||||
|
&& (key.SetDWORDValue(L"CategoryCount",
|
||||||
|
dwCategoryNum) == ERROR_SUCCESS))
|
||||||
|
|
||||||
{
|
{
|
||||||
RegCloseKey(hKey);
|
hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RegSetValueExW(hKey,
|
key.Close();
|
||||||
L"CategoryMessageFile",
|
|
||||||
0,
|
|
||||||
REG_EXPAND_SZ,
|
|
||||||
(LPBYTE) szPath,
|
|
||||||
(DWORD) (wcslen(szPath) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RegSetValueExW(hKey,
|
|
||||||
L"CategoryCount",
|
|
||||||
0,
|
|
||||||
REG_DWORD,
|
|
||||||
(LPBYTE) &dwCategoryNum,
|
|
||||||
sizeof(DWORD)) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
|
||||||
hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
VOID FreeLogs()
|
||||||
FreeLogs(VOID)
|
|
||||||
{
|
{
|
||||||
if (hLog) DeregisterEventSource(hLog);
|
if (hLog)
|
||||||
|
{
|
||||||
|
DeregisterEventSource(hLog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL
|
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
|
||||||
WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
|
|
||||||
{
|
{
|
||||||
if (!SettingsInfo.bLogEnabled) return TRUE;
|
if (!SettingsInfo.bLogEnabled)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ReportEventW(hLog, wType, 0, dwEventID,
|
if (!ReportEventW(hLog, wType, 0, dwEventID,
|
||||||
NULL, 1, 0, &lpMsg, NULL))
|
NULL, 1, 0, &lpMsg, NULL))
|
||||||
|
@ -371,54 +345,51 @@ WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL
|
BOOL GetInstalledVersion_WowUser(ATL::CStringW* szVersionResult,
|
||||||
GetInstalledVersion_WowUser(_Out_opt_ ATL::CStringW* szVersionResult,
|
const ATL::CStringW& RegName,
|
||||||
_In_z_ const ATL::CStringW& RegName,
|
BOOL IsUserKey,
|
||||||
_In_ BOOL IsUserKey,
|
REGSAM keyWow)
|
||||||
_In_ REGSAM keyWow)
|
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
|
||||||
BOOL bHasSucceded = FALSE;
|
BOOL bHasSucceded = FALSE;
|
||||||
|
ATL::CRegKey key;
|
||||||
ATL::CStringW szVersion;
|
ATL::CStringW szVersion;
|
||||||
ATL::CStringW szPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegName;
|
ATL::CStringW szPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegName;
|
||||||
|
|
||||||
if (RegOpenKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
if (key.Open(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
||||||
szPath.GetString(), 0, keyWow | KEY_READ,
|
szPath.GetString(),
|
||||||
&hKey) == ERROR_SUCCESS)
|
keyWow | KEY_READ) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if (szVersionResult != NULL)
|
return FALSE;
|
||||||
{
|
}
|
||||||
DWORD dwSize = MAX_PATH * sizeof(WCHAR);
|
|
||||||
DWORD dwType = REG_SZ;
|
if (szVersionResult != NULL)
|
||||||
if (RegQueryValueExW(hKey,
|
{
|
||||||
L"DisplayVersion",
|
ULONG dwSize = MAX_PATH * sizeof(WCHAR);
|
||||||
NULL,
|
|
||||||
&dwType,
|
if (key.QueryStringValue(L"DisplayVersion",
|
||||||
(LPBYTE) szVersion.GetBuffer(MAX_PATH),
|
szVersion.GetBuffer(MAX_PATH),
|
||||||
&dwSize) == ERROR_SUCCESS)
|
&dwSize) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
szVersion.ReleaseBuffer();
|
szVersion.ReleaseBuffer();
|
||||||
*szVersionResult = szVersion;
|
*szVersionResult = szVersion;
|
||||||
bHasSucceded = TRUE;
|
bHasSucceded = TRUE;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
szVersion.ReleaseBuffer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bHasSucceded = TRUE;
|
|
||||||
szVersion.ReleaseBuffer();
|
szVersion.ReleaseBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bHasSucceded = TRUE;
|
||||||
|
szVersion.ReleaseBuffer();
|
||||||
|
}
|
||||||
|
key.Close();
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
return bHasSucceded;
|
return bHasSucceded;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL GetInstalledVersion(ATL::CStringW * pszVersion, const ATL::CStringW & szRegName)
|
BOOL GetInstalledVersion(ATL::CStringW *pszVersion, const ATL::CStringW &szRegName)
|
||||||
{
|
{
|
||||||
return (!szRegName.IsEmpty()
|
return (!szRegName.IsEmpty()
|
||||||
&& (GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY)
|
&& (GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY)
|
||||||
|
|
|
@ -19,7 +19,7 @@ BOOL
|
||||||
ChooseFolder(HWND hwnd)
|
ChooseFolder(HWND hwnd)
|
||||||
{
|
{
|
||||||
BOOL bRet = FALSE;
|
BOOL bRet = FALSE;
|
||||||
BROWSEINFO bi;
|
BROWSEINFOW bi;
|
||||||
ATL::CStringW szBuf;
|
ATL::CStringW szBuf;
|
||||||
|
|
||||||
szBuf.LoadStringW(hInst, IDS_CHOOSE_FOLDER_TEXT);
|
szBuf.LoadStringW(hInst, IDS_CHOOSE_FOLDER_TEXT);
|
||||||
|
@ -53,8 +53,7 @@ ChooseFolder(HWND hwnd)
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID InitSettingsControls(HWND hDlg, PSETTINGS_INFO Info)
|
||||||
InitSettingsControls(HWND hDlg, PSETTINGS_INFO Info)
|
|
||||||
{
|
{
|
||||||
SendDlgItemMessageW(hDlg, IDC_SAVE_WINDOW_POS, BM_SETCHECK, Info->bSaveWndPos, 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_UPDATE_AVLIST, BM_SETCHECK, Info->bUpdateAtStart, 0);
|
||||||
|
@ -76,9 +75,7 @@ InitSettingsControls(HWND hDlg, PSETTINGS_INFO Info)
|
||||||
SetWindowTextW(GetDlgItem(hDlg, IDC_NO_PROXY_FOR), Info->szNoProxyFor);
|
SetWindowTextW(GetDlgItem(hDlg, IDC_NO_PROXY_FOR), Info->szNoProxyFor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
INT_PTR CALLBACK
|
|
||||||
SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
switch (Msg)
|
switch (Msg)
|
||||||
{
|
{
|
||||||
|
@ -208,8 +205,7 @@ SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID CreateSettingsDlg(HWND hwnd)
|
||||||
CreateSettingsDlg(HWND hwnd)
|
|
||||||
{
|
{
|
||||||
DialogBoxW(hInst,
|
DialogBoxW(hInst,
|
||||||
MAKEINTRESOURCEW(IDD_SETTINGS_DIALOG),
|
MAKEINTRESOURCEW(IDD_SETTINGS_DIALOG),
|
||||||
|
|
|
@ -50,10 +50,10 @@ static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
|
||||||
FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
|
|
||||||
{
|
{
|
||||||
ATL::CStringW szDownloadDir;
|
ATL::CStringW szDownloadDir;
|
||||||
|
|
||||||
pSettingsInfo->bSaveWndPos = TRUE;
|
pSettingsInfo->bSaveWndPos = TRUE;
|
||||||
pSettingsInfo->bUpdateAtStart = FALSE;
|
pSettingsInfo->bUpdateAtStart = FALSE;
|
||||||
pSettingsInfo->bLogEnabled = TRUE;
|
pSettingsInfo->bLogEnabled = TRUE;
|
||||||
|
@ -67,7 +67,9 @@ FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
szDownloadDir.ReleaseBuffer();
|
szDownloadDir.ReleaseBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
szDownloadDir += L"\\RAPPS Downloads";
|
szDownloadDir += L"\\RAPPS Downloads";
|
||||||
ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir,
|
ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir,
|
||||||
|
@ -87,32 +89,26 @@ FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
|
||||||
pSettingsInfo->szNoProxyFor[0] = UNICODE_NULL;
|
pSettingsInfo->szNoProxyFor[0] = UNICODE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL
|
static BOOL LoadSettings()
|
||||||
LoadSettings(VOID)
|
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
ATL::CRegKey RegKey;
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
|
BOOL bResult = FALSE;
|
||||||
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
if (RegKey.Open(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", KEY_READ) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
dwSize = sizeof(SettingsInfo);
|
dwSize = sizeof(SettingsInfo);
|
||||||
if (RegQueryValueExW(hKey, L"Settings", NULL, NULL, (LPBYTE) &SettingsInfo, &dwSize) == ERROR_SUCCESS)
|
bResult = (RegKey.QueryBinaryValue(L"Settings", (PVOID) &SettingsInfo, &dwSize) == ERROR_SUCCESS);
|
||||||
{
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegKey.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID SaveSettings(HWND hwnd)
|
||||||
SaveSettings(HWND hwnd)
|
|
||||||
{
|
{
|
||||||
WINDOWPLACEMENT wp;
|
WINDOWPLACEMENT wp;
|
||||||
HKEY hKey;
|
ATL::CRegKey RegKey;
|
||||||
|
|
||||||
if (SettingsInfo.bSaveWndPos)
|
if (SettingsInfo.bSaveWndPos)
|
||||||
{
|
{
|
||||||
|
@ -123,35 +119,49 @@ SaveSettings(HWND hwnd)
|
||||||
SettingsInfo.Top = wp.rcNormalPosition.top;
|
SettingsInfo.Top = wp.rcNormalPosition.top;
|
||||||
SettingsInfo.Width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
|
SettingsInfo.Width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
|
||||||
SettingsInfo.Height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
|
SettingsInfo.Height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
|
||||||
SettingsInfo.Maximized = (wp.showCmd == SW_MAXIMIZE || (wp.showCmd == SW_SHOWMINIMIZED && (wp.flags & WPF_RESTORETOMAXIMIZED)));
|
SettingsInfo.Maximized = (wp.showCmd == SW_MAXIMIZE
|
||||||
|
|| (wp.showCmd == SW_SHOWMINIMIZED
|
||||||
|
&& (wp.flags & WPF_RESTORETOMAXIMIZED)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", 0, NULL,
|
if (RegKey.Create(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", NULL,
|
||||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
|
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, NULL) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
RegSetValueExW(hKey, L"Settings", 0, REG_BINARY, (LPBYTE) &SettingsInfo, sizeof(SettingsInfo));
|
RegKey.SetBinaryValue(L"Settings", (const PVOID) &SettingsInfo, sizeof(SettingsInfo));
|
||||||
RegCloseKey(hKey);
|
RegKey.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int WINAPI
|
|
||||||
wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
|
#define CMD_KEY_SETUP L"//SETUP"
|
||||||
|
|
||||||
|
VOID CmdParser(LPWSTR lpCmdLine)
|
||||||
{
|
{
|
||||||
WCHAR szWindowClass[] = L"ROSAPPMGR";
|
INT argc;
|
||||||
|
LPWSTR* argv = CommandLineToArgvW(lpCmdLine, &argc);
|
||||||
|
if (!argv || argc < 2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StrCmpW(argv[0], CMD_KEY_SETUP))
|
||||||
|
{
|
||||||
|
//TODO: call cmd app installation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
INT WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd)
|
||||||
|
{
|
||||||
|
LPCWSTR szWindowClass = L"ROSAPPMGR";
|
||||||
HANDLE hMutex = NULL;
|
HANDLE hMutex = NULL;
|
||||||
HACCEL KeyBrd;
|
HACCEL KeyBrd;
|
||||||
MSG Msg;
|
MSG Msg;
|
||||||
|
|
||||||
InitializeAtlModule(hInstance, TRUE);
|
InitializeAtlModule(hInstance, TRUE);
|
||||||
|
|
||||||
switch (GetUserDefaultUILanguage())
|
if (GetUserDefaultUILanguage() == MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT))
|
||||||
{
|
{
|
||||||
case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):
|
|
||||||
SetProcessDefaultLayout(LAYOUT_RTL);
|
SetProcessDefaultLayout(LAYOUT_RTL);
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hInst = hInstance;
|
hInst = hInstance;
|
||||||
|
@ -178,30 +188,30 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nSh
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
|
||||||
hMainWnd = CreateMainWindow();
|
hMainWnd = CreateMainWindow();
|
||||||
if (!hMainWnd) goto Exit;
|
if (hMainWnd)
|
||||||
|
|
||||||
/* Maximize it if we must */
|
|
||||||
ShowWindow(hMainWnd, (SettingsInfo.bSaveWndPos && SettingsInfo.Maximized ? SW_MAXIMIZE : nShowCmd));
|
|
||||||
UpdateWindow(hMainWnd);
|
|
||||||
|
|
||||||
//TODO: get around the ugliness
|
|
||||||
if (SettingsInfo.bUpdateAtStart)
|
|
||||||
GetAvailableApps()->UpdateAppsDB();
|
|
||||||
|
|
||||||
/* Load the menu hotkeys */
|
|
||||||
KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS));
|
|
||||||
|
|
||||||
/* Message Loop */
|
|
||||||
while (GetMessageW(&Msg, NULL, 0, 0))
|
|
||||||
{
|
{
|
||||||
if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
|
/* Maximize it if we must */
|
||||||
|
ShowWindow(hMainWnd, (SettingsInfo.bSaveWndPos && SettingsInfo.Maximized ? SW_MAXIMIZE : nShowCmd));
|
||||||
|
UpdateWindow(hMainWnd);
|
||||||
|
|
||||||
|
//TODO: get around the ugliness
|
||||||
|
if (SettingsInfo.bUpdateAtStart)
|
||||||
|
GetAvailableApps()->UpdateAppsDB();
|
||||||
|
|
||||||
|
/* Load the menu hotkeys */
|
||||||
|
KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS));
|
||||||
|
|
||||||
|
/* Message Loop */
|
||||||
|
while (GetMessageW(&Msg, NULL, 0, 0))
|
||||||
{
|
{
|
||||||
TranslateMessage(&Msg);
|
if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
|
||||||
DispatchMessageW(&Msg);
|
{
|
||||||
|
TranslateMessage(&Msg);
|
||||||
|
DispatchMessageW(&Msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Exit:
|
|
||||||
if (hMutex)
|
if (hMutex)
|
||||||
CloseHandle(hMutex);
|
CloseHandle(hMutex);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue