mirror of
https://github.com/reactos/reactos.git
synced 2025-05-28 13:38:19 +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
|
||||
* PURPOSE: About Dialog
|
||||
* PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
|
||||
* Alexander Shaposhikov (chaez.san@gmail.com)
|
||||
*/
|
||||
#include "defines.h"
|
||||
|
||||
static
|
||||
INT_PTR CALLBACK
|
||||
AboutDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
static INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (Msg)
|
||||
if (Msg == WM_COMMAND && LOWORD(wParam) == IDOK)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDOK:
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
return EndDialog(hDlg, LOWORD(wParam));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VOID
|
||||
ShowAboutDialog(VOID)
|
||||
VOID ShowAboutDialog()
|
||||
{
|
||||
DialogBoxW(hInst,
|
||||
MAKEINTRESOURCEW(IDD_ABOUT_DIALOG),
|
||||
|
|
|
@ -288,7 +288,10 @@ BOOL CAvailableApps::EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnu
|
|||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (GetFileAttributesW(m_szCabPath) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
CDownloadManager::DownloadApplicationsDB(APPLICATION_DATABASE_URL);
|
||||
}
|
||||
|
||||
|
||||
ExtractFilesFromCab(m_szCabPath, m_szAppsPath);
|
||||
hFind = FindFirstFileW(m_szSearchPath.GetString(), &FindFileData);
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#include "rosui.h"
|
||||
#include "dialogs.h"
|
||||
#include "misc.h"
|
||||
|
||||
#ifdef USE_CERT_PINNING
|
||||
#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
|
||||
|
||||
inline VOID
|
||||
MessageBox_LoadString(HWND hMainWnd, INT StringID)
|
||||
inline VOID MessageBox_LoadString(HWND hMainWnd, INT StringID)
|
||||
{
|
||||
ATL::CString szMsgText;
|
||||
if (szMsgText.LoadStringW(hInst, StringID))
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
|
||||
static HANDLE hLog = NULL;
|
||||
|
||||
typedef struct
|
||||
struct ERF
|
||||
{
|
||||
int erfOper;
|
||||
int erfType;
|
||||
BOOL fError;
|
||||
} ERF, *PERF;
|
||||
};
|
||||
|
||||
struct FILELIST
|
||||
{
|
||||
|
@ -48,9 +48,7 @@ struct SESSION
|
|||
typedef HRESULT(WINAPI *fnExtract)(SESSION *dest, LPCSTR szCabName);
|
||||
fnExtract pfnExtract;
|
||||
|
||||
|
||||
int
|
||||
GetWindowWidth(HWND hwnd)
|
||||
INT GetWindowWidth(HWND hwnd)
|
||||
{
|
||||
RECT Rect;
|
||||
|
||||
|
@ -58,8 +56,7 @@ GetWindowWidth(HWND hwnd)
|
|||
return (Rect.right - Rect.left);
|
||||
}
|
||||
|
||||
int
|
||||
GetWindowHeight(HWND hwnd)
|
||||
INT GetWindowHeight(HWND hwnd)
|
||||
{
|
||||
RECT Rect;
|
||||
|
||||
|
@ -67,8 +64,7 @@ GetWindowHeight(HWND hwnd)
|
|||
return (Rect.bottom - Rect.top);
|
||||
}
|
||||
|
||||
int
|
||||
GetClientWindowWidth(HWND hwnd)
|
||||
INT GetClientWindowWidth(HWND hwnd)
|
||||
{
|
||||
RECT Rect;
|
||||
|
||||
|
@ -76,8 +72,7 @@ GetClientWindowWidth(HWND hwnd)
|
|||
return (Rect.right - Rect.left);
|
||||
}
|
||||
|
||||
int
|
||||
GetClientWindowHeight(HWND hwnd)
|
||||
INT GetClientWindowHeight(HWND hwnd)
|
||||
{
|
||||
RECT Rect;
|
||||
|
||||
|
@ -85,33 +80,33 @@ GetClientWindowHeight(HWND hwnd)
|
|||
return (Rect.bottom - Rect.top);
|
||||
}
|
||||
|
||||
VOID
|
||||
CopyTextToClipboard(LPCWSTR lpszText)
|
||||
VOID CopyTextToClipboard(LPCWSTR lpszText)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if (OpenClipboard(NULL))
|
||||
if (!OpenClipboard(NULL))
|
||||
{
|
||||
HGLOBAL ClipBuffer;
|
||||
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();
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
SetWelcomeText(VOID)
|
||||
VOID SetWelcomeText()
|
||||
{
|
||||
ATL::CStringW szText;
|
||||
|
||||
|
@ -125,12 +120,11 @@ SetWelcomeText(VOID)
|
|||
InsertRichEditText(szText, CFM_LINK);
|
||||
}
|
||||
|
||||
VOID
|
||||
ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
|
||||
VOID ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
|
||||
{
|
||||
HMENU hMenu = NULL;
|
||||
HMENU hPopupMenu;
|
||||
MENUITEMINFO mii;
|
||||
MENUITEMINFO ItemInfo;
|
||||
POINT pt;
|
||||
|
||||
if (MenuID)
|
||||
|
@ -139,15 +133,20 @@ ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
|
|||
hPopupMenu = GetSubMenu(hMenu, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
hPopupMenu = GetMenu(hwnd);
|
||||
}
|
||||
|
||||
ZeroMemory(&mii, sizeof(mii));
|
||||
mii.cbSize = sizeof(mii);
|
||||
mii.fMask = MIIM_STATE;
|
||||
GetMenuItemInfoW(hPopupMenu, DefaultItem, FALSE, &mii);
|
||||
ZeroMemory(&ItemInfo, sizeof(ItemInfo));
|
||||
ItemInfo.cbSize = sizeof(ItemInfo);
|
||||
ItemInfo.fMask = MIIM_STATE;
|
||||
|
||||
if (!(mii.fState & MFS_GRAYED))
|
||||
GetMenuItemInfoW(hPopupMenu, DefaultItem, FALSE, &ItemInfo);
|
||||
|
||||
if (!(ItemInfo.fState & MFS_GRAYED))
|
||||
{
|
||||
SetMenuDefaultItem(hPopupMenu, DefaultItem, FALSE);
|
||||
}
|
||||
|
||||
GetCursorPos(&pt);
|
||||
|
||||
|
@ -155,18 +154,17 @@ ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem)
|
|||
TrackPopupMenu(hPopupMenu, 0, pt.x, pt.y, 0, hMainWnd, NULL);
|
||||
|
||||
if (hMenu)
|
||||
{
|
||||
DestroyMenu(hMenu);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
StartProcess(ATL::CStringW &Path, BOOL Wait)
|
||||
{
|
||||
BOOL result = StartProcess(const_cast<LPWSTR>(Path.GetString()), Wait);
|
||||
return result;
|
||||
BOOL StartProcess(ATL::CStringW &Path, BOOL Wait)
|
||||
{
|
||||
return StartProcess(const_cast<LPWSTR>(Path.GetString()), Wait);;
|
||||
}
|
||||
|
||||
BOOL
|
||||
StartProcess(LPWSTR lpPath, BOOL Wait)
|
||||
BOOL StartProcess(LPWSTR lpPath, BOOL Wait)
|
||||
{
|
||||
PROCESS_INFORMATION pi;
|
||||
STARTUPINFOW si;
|
||||
|
@ -184,7 +182,11 @@ StartProcess(LPWSTR lpPath, BOOL Wait)
|
|||
}
|
||||
|
||||
CloseHandle(pi.hThread);
|
||||
if (Wait) EnableWindow(hMainWnd, FALSE);
|
||||
|
||||
if (Wait)
|
||||
{
|
||||
EnableWindow(hMainWnd, FALSE);
|
||||
}
|
||||
|
||||
while (Wait)
|
||||
{
|
||||
|
@ -194,7 +196,7 @@ StartProcess(LPWSTR lpPath, BOOL Wait)
|
|||
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
DispatchMessageW(&msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -216,8 +218,7 @@ StartProcess(LPWSTR lpPath, BOOL Wait)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
GetStorageDirectory(ATL::CStringW& Directory)
|
||||
BOOL GetStorageDirectory(ATL::CStringW& Directory)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
BOOL
|
||||
ExtractFilesFromCab(const ATL::CStringW &CabName, const ATL::CStringW &OutputPath)
|
||||
BOOL ExtractFilesFromCab(const ATL::CStringW &CabName, const ATL::CStringW &OutputPath)
|
||||
{
|
||||
return ExtractFilesFromCab(CabName.GetString(), OutputPath.GetString());
|
||||
}
|
||||
|
||||
BOOL
|
||||
ExtractFilesFromCab(LPCWSTR lpCabName, LPCWSTR lpOutputPath)
|
||||
BOOL ExtractFilesFromCab(LPCWSTR lpCabName, LPCWSTR lpOutputPath)
|
||||
{
|
||||
HINSTANCE hCabinetDll;
|
||||
CHAR szCabName[MAX_PATH];
|
||||
|
@ -275,92 +274,67 @@ ExtractFilesFromCab(LPCWSTR lpCabName, LPCWSTR lpOutputPath)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
VOID
|
||||
InitLogs(VOID)
|
||||
VOID InitLogs()
|
||||
{
|
||||
WCHAR szBuf[MAX_PATH] = L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\ReactOS Application Manager";
|
||||
if (!SettingsInfo.bLogEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WCHAR szPath[MAX_PATH];
|
||||
DWORD dwCategoryNum = 1;
|
||||
DWORD dwDisp, dwData;
|
||||
HKEY hKey;
|
||||
ATL::CRegKey key;
|
||||
|
||||
if (!SettingsInfo.bLogEnabled) return;
|
||||
|
||||
if (RegCreateKeyExW(HKEY_LOCAL_MACHINE,
|
||||
szBuf, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE, NULL, &hKey, &dwDisp) != ERROR_SUCCESS)
|
||||
if (key.Create(HKEY_LOCAL_MACHINE,
|
||||
L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\ReactOS Application Manager",
|
||||
REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &dwDisp) != ERROR_SUCCESS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
|
||||
EVENTLOG_INFORMATION_TYPE;
|
||||
|
||||
if (RegSetValueExW(hKey,
|
||||
L"TypesSupported",
|
||||
0,
|
||||
REG_DWORD,
|
||||
(LPBYTE) &dwData,
|
||||
sizeof(DWORD)) != ERROR_SUCCESS)
|
||||
if ((key.SetStringValue(L"EventMessageFile",
|
||||
szPath,
|
||||
REG_EXPAND_SZ) == ERROR_SUCCESS)
|
||||
&& (key.SetStringValue(L"CategoryMessageFile",
|
||||
szPath,
|
||||
REG_EXPAND_SZ) == ERROR_SUCCESS)
|
||||
&& (key.SetDWORDValue(L"TypesSupported",
|
||||
dwData) == ERROR_SUCCESS)
|
||||
&& (key.SetDWORDValue(L"CategoryCount",
|
||||
dwCategoryNum) == ERROR_SUCCESS))
|
||||
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return;
|
||||
hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
|
||||
}
|
||||
|
||||
if (RegSetValueExW(hKey,
|
||||
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");
|
||||
key.Close();
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
FreeLogs(VOID)
|
||||
VOID FreeLogs()
|
||||
{
|
||||
if (hLog) DeregisterEventSource(hLog);
|
||||
if (hLog)
|
||||
{
|
||||
DeregisterEventSource(hLog);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
|
||||
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
|
||||
{
|
||||
if (!SettingsInfo.bLogEnabled) return TRUE;
|
||||
if (!SettingsInfo.bLogEnabled)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (!ReportEventW(hLog, wType, 0, dwEventID,
|
||||
NULL, 1, 0, &lpMsg, NULL))
|
||||
|
@ -371,54 +345,51 @@ WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
GetInstalledVersion_WowUser(_Out_opt_ ATL::CStringW* szVersionResult,
|
||||
_In_z_ const ATL::CStringW& RegName,
|
||||
_In_ BOOL IsUserKey,
|
||||
_In_ REGSAM keyWow)
|
||||
BOOL GetInstalledVersion_WowUser(ATL::CStringW* szVersionResult,
|
||||
const ATL::CStringW& RegName,
|
||||
BOOL IsUserKey,
|
||||
REGSAM keyWow)
|
||||
{
|
||||
HKEY hKey;
|
||||
BOOL bHasSucceded = FALSE;
|
||||
ATL::CRegKey key;
|
||||
ATL::CStringW szVersion;
|
||||
ATL::CStringW szPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + RegName;
|
||||
|
||||
if (RegOpenKeyExW(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
||||
szPath.GetString(), 0, keyWow | KEY_READ,
|
||||
&hKey) == ERROR_SUCCESS)
|
||||
if (key.Open(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
|
||||
szPath.GetString(),
|
||||
keyWow | KEY_READ) != ERROR_SUCCESS)
|
||||
{
|
||||
if (szVersionResult != NULL)
|
||||
{
|
||||
DWORD dwSize = MAX_PATH * sizeof(WCHAR);
|
||||
DWORD dwType = REG_SZ;
|
||||
if (RegQueryValueExW(hKey,
|
||||
L"DisplayVersion",
|
||||
NULL,
|
||||
&dwType,
|
||||
(LPBYTE) szVersion.GetBuffer(MAX_PATH),
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (szVersionResult != NULL)
|
||||
{
|
||||
ULONG dwSize = MAX_PATH * sizeof(WCHAR);
|
||||
|
||||
if (key.QueryStringValue(L"DisplayVersion",
|
||||
szVersion.GetBuffer(MAX_PATH),
|
||||
&dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
szVersion.ReleaseBuffer();
|
||||
*szVersionResult = szVersion;
|
||||
bHasSucceded = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
szVersion.ReleaseBuffer();
|
||||
}
|
||||
{
|
||||
szVersion.ReleaseBuffer();
|
||||
*szVersionResult = szVersion;
|
||||
bHasSucceded = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bHasSucceded = TRUE;
|
||||
szVersion.ReleaseBuffer();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bHasSucceded = TRUE;
|
||||
szVersion.ReleaseBuffer();
|
||||
}
|
||||
key.Close();
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return bHasSucceded;
|
||||
}
|
||||
|
||||
BOOL GetInstalledVersion(ATL::CStringW * pszVersion, const ATL::CStringW & szRegName)
|
||||
BOOL GetInstalledVersion(ATL::CStringW *pszVersion, const ATL::CStringW &szRegName)
|
||||
{
|
||||
return (!szRegName.IsEmpty()
|
||||
&& (GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY)
|
||||
|
|
|
@ -19,7 +19,7 @@ BOOL
|
|||
ChooseFolder(HWND hwnd)
|
||||
{
|
||||
BOOL bRet = FALSE;
|
||||
BROWSEINFO bi;
|
||||
BROWSEINFOW bi;
|
||||
ATL::CStringW szBuf;
|
||||
|
||||
szBuf.LoadStringW(hInst, IDS_CHOOSE_FOLDER_TEXT);
|
||||
|
@ -53,8 +53,7 @@ ChooseFolder(HWND hwnd)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
static VOID
|
||||
InitSettingsControls(HWND hDlg, PSETTINGS_INFO Info)
|
||||
static VOID InitSettingsControls(HWND hDlg, PSETTINGS_INFO Info)
|
||||
{
|
||||
SendDlgItemMessageW(hDlg, IDC_SAVE_WINDOW_POS, BM_SETCHECK, Info->bSaveWndPos, 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);
|
||||
}
|
||||
|
||||
static
|
||||
INT_PTR CALLBACK
|
||||
SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
static INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (Msg)
|
||||
{
|
||||
|
@ -208,8 +205,7 @@ SettingsDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
VOID
|
||||
CreateSettingsDlg(HWND hwnd)
|
||||
VOID CreateSettingsDlg(HWND hwnd)
|
||||
{
|
||||
DialogBoxW(hInst,
|
||||
MAKEINTRESOURCEW(IDD_SETTINGS_DIALOG),
|
||||
|
|
|
@ -50,10 +50,10 @@ static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize)
|
|||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
|
||||
VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
|
||||
{
|
||||
ATL::CStringW szDownloadDir;
|
||||
|
||||
pSettingsInfo->bSaveWndPos = TRUE;
|
||||
pSettingsInfo->bUpdateAtStart = FALSE;
|
||||
pSettingsInfo->bLogEnabled = TRUE;
|
||||
|
@ -67,7 +67,9 @@ FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
szDownloadDir.ReleaseBuffer();
|
||||
}
|
||||
|
||||
szDownloadDir += L"\\RAPPS Downloads";
|
||||
ATL::CStringW::CopyChars(pSettingsInfo->szDownloadDir,
|
||||
|
@ -87,32 +89,26 @@ FillDefaultSettings(PSETTINGS_INFO pSettingsInfo)
|
|||
pSettingsInfo->szNoProxyFor[0] = UNICODE_NULL;
|
||||
}
|
||||
|
||||
static BOOL
|
||||
LoadSettings(VOID)
|
||||
static BOOL LoadSettings()
|
||||
{
|
||||
HKEY hKey;
|
||||
ATL::CRegKey RegKey;
|
||||
DWORD dwSize;
|
||||
|
||||
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||
BOOL bResult = FALSE;
|
||||
if (RegKey.Open(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", KEY_READ) == ERROR_SUCCESS)
|
||||
{
|
||||
dwSize = sizeof(SettingsInfo);
|
||||
if (RegQueryValueExW(hKey, L"Settings", NULL, NULL, (LPBYTE) &SettingsInfo, &dwSize) == ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(hKey);
|
||||
return TRUE;
|
||||
}
|
||||
bResult = (RegKey.QueryBinaryValue(L"Settings", (PVOID) &SettingsInfo, &dwSize) == ERROR_SUCCESS);
|
||||
|
||||
RegCloseKey(hKey);
|
||||
RegKey.Close();
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
VOID
|
||||
SaveSettings(HWND hwnd)
|
||||
VOID SaveSettings(HWND hwnd)
|
||||
{
|
||||
WINDOWPLACEMENT wp;
|
||||
HKEY hKey;
|
||||
ATL::CRegKey RegKey;
|
||||
|
||||
if (SettingsInfo.bSaveWndPos)
|
||||
{
|
||||
|
@ -123,35 +119,49 @@ SaveSettings(HWND hwnd)
|
|||
SettingsInfo.Top = wp.rcNormalPosition.top;
|
||||
SettingsInfo.Width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
|
||||
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,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS)
|
||||
if (RegKey.Create(HKEY_CURRENT_USER, L"Software\\ReactOS\\rapps", NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
RegSetValueExW(hKey, L"Settings", 0, REG_BINARY, (LPBYTE) &SettingsInfo, sizeof(SettingsInfo));
|
||||
RegCloseKey(hKey);
|
||||
RegKey.SetBinaryValue(L"Settings", (const PVOID) &SettingsInfo, sizeof(SettingsInfo));
|
||||
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;
|
||||
HACCEL KeyBrd;
|
||||
MSG Msg;
|
||||
|
||||
InitializeAtlModule(hInstance, TRUE);
|
||||
|
||||
switch (GetUserDefaultUILanguage())
|
||||
if (GetUserDefaultUILanguage() == MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT))
|
||||
{
|
||||
case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT):
|
||||
SetProcessDefaultLayout(LAYOUT_RTL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
hInst = hInstance;
|
||||
|
@ -178,30 +188,30 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nSh
|
|||
InitCommonControls();
|
||||
|
||||
hMainWnd = CreateMainWindow();
|
||||
if (!hMainWnd) goto Exit;
|
||||
|
||||
/* 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 (hMainWnd)
|
||||
{
|
||||
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);
|
||||
DispatchMessageW(&Msg);
|
||||
if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
|
||||
{
|
||||
TranslateMessage(&Msg);
|
||||
DispatchMessageW(&Msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Exit:
|
||||
if (hMutex)
|
||||
CloseHandle(hMutex);
|
||||
|
||||
|
|
Loading…
Reference in a new issue