[RAPPS]
authorAlexander Shaposhnikov <sanchaez@reactos.org>
Wed, 2 Aug 2017 12:50:53 +0000 (12:50 +0000)
committerAlexander Shaposhnikov <sanchaez@reactos.org>
Wed, 2 Aug 2017 12:50:53 +0000 (12:50 +0000)
- Split the rapps.h into multiple headers for easier managing
- Moved headers to include/
- Corrected some typos and moved functions around

svn path=/branches/GSoC_2017/rapps/; revision=75469

24 files changed:
reactos/base/applications/rapps/CMakeLists.txt
reactos/base/applications/rapps/aboutdlg.cpp
reactos/base/applications/rapps/available.cpp
reactos/base/applications/rapps/gui.cpp
reactos/base/applications/rapps/include/available.h [new file with mode: 0644]
reactos/base/applications/rapps/include/crichedit.h [moved from reactos/base/applications/rapps/crichedit.h with 99% similarity]
reactos/base/applications/rapps/include/defines.h [new file with mode: 0644]
reactos/base/applications/rapps/include/dialogs.h [new file with mode: 0644]
reactos/base/applications/rapps/include/gui.h [new file with mode: 0644]
reactos/base/applications/rapps/include/installed.h [new file with mode: 0644]
reactos/base/applications/rapps/include/misc.h [new file with mode: 0644]
reactos/base/applications/rapps/include/rapps.h [new file with mode: 0644]
reactos/base/applications/rapps/include/resource.h [moved from reactos/base/applications/rapps/resource.h with 100% similarity]
reactos/base/applications/rapps/include/rosui.h [moved from reactos/base/applications/rapps/rosui.h with 99% similarity]
reactos/base/applications/rapps/include/winmain.h [new file with mode: 0644]
reactos/base/applications/rapps/installdlg.cpp
reactos/base/applications/rapps/installed.cpp
reactos/base/applications/rapps/integrity.cpp
reactos/base/applications/rapps/lang/en-US.rc
reactos/base/applications/rapps/loaddlg.cpp
reactos/base/applications/rapps/misc.cpp
reactos/base/applications/rapps/rapps.h [deleted file]
reactos/base/applications/rapps/settingsdlg.cpp
reactos/base/applications/rapps/winmain.cpp

index 0b89c35..31189c7 100644 (file)
@@ -4,6 +4,7 @@ set_cpp(WITH_RUNTIME)
 
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
 include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/cryptlib)
+include_directories(include)
 
 list(APPEND SOURCE
     aboutdlg.cpp
@@ -16,7 +17,8 @@ list(APPEND SOURCE
     misc.cpp
     settingsdlg.cpp
     winmain.cpp
-    rapps.h)
+    include/rapps.h
+)
 
 add_definitions(-DUSE_CERT_PINNING)
 file(GLOB_RECURSE rapps_rc_deps res/*.*)
@@ -25,7 +27,7 @@ add_executable(rapps ${SOURCE} rapps.rc)
 set_module_type(rapps win32gui UNICODE)
 target_link_libraries(rapps atlnew uuid wine)
 add_importlibs(rapps advapi32 comctl32 gdi32 wininet user32 shell32 shlwapi ole32 msvcrt kernel32 ntdll)
-add_pch(rapps rapps.h SOURCE)
+add_pch(rapps include/rapps.h SOURCE)
 add_dependencies(rapps rappsmsg)
 add_message_headers(ANSI rappsmsg.mc)
 add_cd_file(TARGET rapps DESTINATION reactos/system32 FOR all)
index dadf77b..8c0e22e 100644 (file)
@@ -5,8 +5,7 @@
  * PURPOSE:         About Dialog
  * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
  */
-
-#include "rapps.h"
+#include "defines.h"
 
 static
 INT_PTR CALLBACK
@@ -32,8 +31,8 @@ AboutDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
 VOID
 ShowAboutDialog(VOID)
 {
-    DialogBox(hInst,
-              MAKEINTRESOURCE(IDD_ABOUT_DIALOG),
+    DialogBoxW(hInst,
+              MAKEINTRESOURCEW(IDD_ABOUT_DIALOG),
               hMainWnd,
               AboutDlgProc);
 }
index c3419b5..b194ebe 100644 (file)
@@ -7,8 +7,15 @@
  *                  Ismael Ferreras Morezuelas (swyterzone+ros@gmail.com)
  *                  Alexander Shaposhnikov     (chaez.san@gmail.com)
  */
+#include "defines.h"
 
-#include "rapps.h"
+#include "available.h"
+#include "misc.h"
+#include "dialogs.h"
+
+#include <atlcoll.h>
+#include <atlsimpcoll.h>
+#include <atlstr.h>
 
  // CAvailableApplicationInfo
 CAvailableApplicationInfo::CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam)
@@ -28,6 +35,7 @@ VOID CAvailableApplicationInfo::RefreshAppInfo()
     }
 }
 
+// Lazily load general info from the file
 VOID CAvailableApplicationInfo::RetrieveGeneralInfo()
 {
     Category = m_Parser.GetInt(L"Category");
@@ -481,4 +489,4 @@ UINT CConfigParser::GetInt(const ATL::CStringW& KeyName)
 
     return (UINT) (result <= 0) ? 0 : result;
 }
-// CConfigParser
\ No newline at end of file
+// CConfigParser
index 50f190e..f9e0767 100644 (file)
@@ -3,8 +3,11 @@
  * AUTHORS:     David Quintana             <gigaherz@gmail.com>
  *              Alexander Shaposhnikov     <chaez.san@gmail.com>
  */
+#include "defines.h"
 
 #include "rapps.h"
+#include "rosui.h"
+#include "crichedit.h"
 
 #include <shlobj_undoc.h>
 #include <shlguid_undoc.h>
 #include <atlwin.h>
 #include <wininet.h>
 #include <shellutils.h>
-
 #include <rosctrls.h>
 
-#include "rosui.h"
-#include "crichedit.h"
-
 #define SEARCH_TIMER_ID 'SR'
+#define LISTVIEW_ICON_SIZE 24
+#define TREEVIEW_ICON_SIZE 24
 
 HWND hListView = NULL;
 
+INT
+GetSystemColorDepth(VOID)
+{
+    DEVMODEW pDevMode;
+    INT ColorDepth;
+
+    pDevMode.dmSize = sizeof(pDevMode);
+    pDevMode.dmDriverExtra = 0;
+
+    if (!EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &pDevMode))
+    {
+        /* TODO: Error message */
+        return ILC_COLOR;
+    }
+
+    switch (pDevMode.dmBitsPerPel)
+    {
+    case 32: ColorDepth = ILC_COLOR32; break;
+    case 24: ColorDepth = ILC_COLOR24; break;
+    case 16: ColorDepth = ILC_COLOR16; break;
+    case  8: ColorDepth = ILC_COLOR8;  break;
+    case  4: ColorDepth = ILC_COLOR4;  break;
+    default: ColorDepth = ILC_COLOR;   break;
+    }
+
+    return ColorDepth;
+}
+
 class CAvailableAppView
 {
     static inline VOID InsertTextAfterLoaded_RichEdit(UINT uStringID,
diff --git a/reactos/base/applications/rapps/include/available.h b/reactos/base/applications/rapps/include/available.h
new file mode 100644 (file)
index 0000000..c351dc1
--- /dev/null
@@ -0,0 +1,148 @@
+#pragma once
+#include <windef.h>
+#include <atlstr.h> 
+#include <atlsimpcoll.h>
+#include <atlcoll.h>
+
+/* EnumType flags for EnumAvailableApplications */
+#define ENUM_ALL_AVAILABLE     0
+#define ENUM_CAT_AUDIO         1
+#define ENUM_CAT_VIDEO         2
+#define ENUM_CAT_GRAPHICS      3
+#define ENUM_CAT_GAMES         4
+#define ENUM_CAT_INTERNET      5
+#define ENUM_CAT_OFFICE        6
+#define ENUM_CAT_DEVEL         7
+#define ENUM_CAT_EDU           8
+#define ENUM_CAT_ENGINEER      9
+#define ENUM_CAT_FINANCE       10
+#define ENUM_CAT_SCIENCE       11
+#define ENUM_CAT_TOOLS         12
+#define ENUM_CAT_DRIVERS       13
+#define ENUM_CAT_LIBS          14
+#define ENUM_CAT_OTHER         15
+
+#define ENUM_AVAILABLE_MIN ENUM_ALL_AVAILABLE
+#define ENUM_AVAILABLE_MAX ENUM_CAT_OTHER
+
+#define IS_AVAILABLE_ENUM(a) (a >= ENUM_AVAILABLE_MIN && a <= ENUM_AVAILABLE_MAX)
+
+typedef enum
+{
+    None,
+    OpenSource,
+    Freeware,
+    Trial,
+    Max = Trial,
+    Min = None
+} LICENSE_TYPE, *PLICENSE_TYPE;
+
+class CConfigParser
+{
+    // Locale names cache
+    const static INT m_cchLocaleSize = 5;
+
+    static ATL::CStringW m_szLocaleID;
+    static ATL::CStringW m_szCachedINISectionLocale;
+    static ATL::CStringW m_szCachedINISectionLocaleNeutral;
+
+    const LPCWSTR STR_VERSION_CURRENT = L"CURRENT";
+    const ATL::CStringW szConfigPath;
+
+    static ATL::CStringW GetINIFullPath(const ATL::CStringW& FileName);
+    static VOID CacheINILocaleLazy();
+
+public:
+    static const ATL::CStringW& GetLocale();
+    static INT CConfigParser::GetLocaleSize();
+
+    CConfigParser(const ATL::CStringW& FileName);
+
+    UINT GetString(const ATL::CStringW& KeyName, ATL::CStringW& ResultString);
+    UINT GetInt(const ATL::CStringW& KeyName);
+};
+
+typedef struct
+{
+    INT Category;
+    LICENSE_TYPE LicenseType;
+    ATL::CStringW szName;
+    ATL::CStringW szRegName;
+    ATL::CStringW szVersion;
+    ATL::CStringW szLicense;
+    ATL::CStringW szDesc;
+    ATL::CStringW szSize;
+    ATL::CStringW szUrlSite;
+    ATL::CStringW szUrlDownload;
+    ATL::CStringW szCDPath;
+    ATL::CSimpleArray<LCID> Languages;
+
+    // Caching mechanism related entries
+    ATL::CStringW sFileName;
+    FILETIME ftCacheStamp;
+
+    // Optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form)
+    ATL::CStringW szSHA1;
+
+} APPLICATION_INFO, *PAPPLICATION_INFO;
+
+extern ATL::CAtlList<PAPPLICATION_INFO> InfoList;
+
+typedef BOOL(CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info, LPCWSTR szFolderPath);
+
+struct CAvailableApplicationInfo : public APPLICATION_INFO
+{
+    ATL::CStringW szInstalledVersion;
+    CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam);
+
+    // Load all info from the file
+    VOID RefreshAppInfo();
+    BOOL HasLanguageInfo() const;
+    BOOL HasNativeLanguage() const;
+    BOOL HasEnglishLanguage() const;
+    BOOL IsInstalled() const;
+    BOOL HasInstalledVersion() const;
+    BOOL HasUpdate() const;
+
+    // Set a timestamp
+    VOID SetLastWriteTime(FILETIME* ftTime);
+
+private:
+    BOOL m_IsInstalled = FALSE;
+    BOOL m_HasLanguageInfo = FALSE;
+    BOOL m_HasInstalledVersion = FALSE;
+    CConfigParser m_Parser;
+
+    inline BOOL GetString(LPCWSTR lpKeyName,
+                          ATL::CStringW& ReturnedString);
+
+    // Lazily load general info from the file
+    VOID RetrieveGeneralInfo();
+    VOID RetrieveInstalledStatus();
+    VOID RetrieveInstalledVersion();
+    VOID RetrieveLanguages();
+    VOID RetrieveLicenseType();
+    inline BOOL FindInLanguages(LCID what) const;
+};
+
+class CAvailableApps
+{
+    ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
+    ATL::CStringW m_szPath;
+    ATL::CStringW m_szCabPath;
+    ATL::CStringW m_szAppsPath;
+    ATL::CStringW m_szSearchPath;
+
+public:
+    CAvailableApps();
+    VOID FreeCachedEntries();
+    BOOL DeleteCurrentAppsDB();
+    BOOL UpdateAppsDB();
+    BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc);
+    const ATL::CStringW& GetFolderPath();
+    const ATL::CStringW& GetAppPath();
+    const ATL::CStringW& GetCabPath();
+    const LPCWSTR GetFolderPathString();
+    const LPCWSTR GetAppPathString();
+    const LPCWSTR GetCabPathString();
+};
\ No newline at end of file
diff --git a/reactos/base/applications/rapps/include/defines.h b/reactos/base/applications/rapps/include/defines.h
new file mode 100644 (file)
index 0000000..ef4ddfb
--- /dev/null
@@ -0,0 +1,34 @@
+#pragma once
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+#define COBJMACROS
+#include <tchar.h>
+#include <stdarg.h>
+
+#include <windef.h>
+#include <winbase.h>
+#include <winreg.h>
+#include <wingdi.h>
+#include <winnls.h>
+#include <winuser.h>
+#include <wincon.h>
+#include <richedit.h>
+#include <shellapi.h>
+#include <shlobj.h>
+#include <shlwapi.h>
+#include <stdio.h>
+#include <strsafe.h>
+#include <ndk/rtlfuncs.h>
+#include <atlcoll.h>
+#include <atlsimpcoll.h>
+#include <atlstr.h> 
+#include <rappsmsg.h>
+
+#include "resource.h"
+#include "winmain.h"
+
+#define APPLICATION_DATABASE_URL L"https://svn.reactos.org/packages/rappmgr.cab"
+#define MAX_STR_LEN              256
+#define ENUM_ALL_COMPONENTS      30
\ No newline at end of file
diff --git a/reactos/base/applications/rapps/include/dialogs.h b/reactos/base/applications/rapps/include/dialogs.h
new file mode 100644 (file)
index 0000000..db0e218
--- /dev/null
@@ -0,0 +1,41 @@
+#pragma once
+
+#include "available.h"
+
+#include <windef.h>
+#include <atlsimpcoll.h>
+
+// Download dialog (loaddlg.cpp)
+class CDowloadingAppsListView;
+
+class CDownloadManager
+{
+    static PAPPLICATION_INFO AppInfo;
+    static ATL::CSimpleArray<PAPPLICATION_INFO> AppsToInstallList;
+    static CDowloadingAppsListView DownloadsListView;
+    static INT iCurrentApp;
+
+public:
+    static INT_PTR CALLBACK DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+    static LRESULT CALLBACK DownloadProgressProc(HWND hWnd, 
+                                                 UINT uMsg, 
+                                                 WPARAM wParam, 
+                                                 LPARAM lParam, 
+                                                 UINT_PTR uIdSubclass, 
+                                                 DWORD_PTR dwRefData);
+
+    static DWORD WINAPI ThreadFunc(LPVOID Context);
+    static BOOL DownloadListOfApplications(const ATL::CSimpleArray<PAPPLICATION_INFO>& AppsList);
+    static BOOL DownloadApplication(PAPPLICATION_INFO pAppInfo);
+    static VOID DownloadApplicationsDB(LPCWSTR lpUrl);
+    static VOID LaunchDownloadDialog();
+};
+
+// Settings dialog (settingsdlg.cpp)
+VOID CreateSettingsDlg(HWND hwnd);
+
+// About dialog (aboutdlg.cpp)
+VOID ShowAboutDialog(VOID);
+
+// Installation dialog (installdlg.cpp)
+//BOOL InstallApplication(INT Index);
\ No newline at end of file
diff --git a/reactos/base/applications/rapps/include/gui.h b/reactos/base/applications/rapps/include/gui.h
new file mode 100644 (file)
index 0000000..0023453
--- /dev/null
@@ -0,0 +1,20 @@
+#pragma once
+#include <windef.h>
+#include <atlstr.h>
+
+class CAvailableApps;
+
+HWND CreateMainWindow();
+DWORD_PTR ListViewGetlParam(INT item);
+INT ListViewAddItem(INT ItemIndex, INT IconIndex, LPWSTR lpName, LPARAM lParam);
+VOID SetStatusBarText(LPCWSTR szText);
+VOID NewRichEditText(LPCWSTR szText, DWORD flags);
+VOID InsertRichEditText(LPCWSTR szText, DWORD flags);
+
+VOID SetStatusBarText(const ATL::CStringW& szText);
+INT ListViewAddItem(INT ItemIndex, INT IconIndex, ATL::CStringW & Name, LPARAM lParam);
+VOID NewRichEditText(const ATL::CStringW& szText, DWORD flags);
+VOID InsertRichEditText(const ATL::CStringW& szText, DWORD flags);
+CAvailableApps * GetAvailableApps();
+extern HWND hListView;
+extern ATL::CStringW szSearchPattern;
\ No newline at end of file
diff --git a/reactos/base/applications/rapps/include/installed.h b/reactos/base/applications/rapps/include/installed.h
new file mode 100644 (file)
index 0000000..6b6112c
--- /dev/null
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <windef.h>
+#include <atlstr.h>
+
+#define ENUM_APPLICATIONS      31
+#define ENUM_UPDATES           32
+
+#define ENUM_INSTALLED_MIN ENUM_ALL_COMPONENTS
+#define ENUM_INSTALLED_MAX ENUM_UPDATES
+
+#define IS_INSTALLED_ENUM(a) (a >= ENUM_INSTALLED_MIN && a <= ENUM_INSTALLED_MAX)
+
+struct INSTALLED_INFO
+{
+    HKEY hRootKey;
+    HKEY hSubKey;
+    ATL::CStringW szKeyName;
+};
+typedef INSTALLED_INFO *PINSTALLED_INFO;
+typedef BOOL(CALLBACK *APPENUMPROC)(INT ItemIndex, ATL::CStringW &Name, PINSTALLED_INFO Info);
+
+BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc);
+BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR szString);
+BOOL GetApplicationString(HKEY hKey, LPCWSTR RegName, ATL::CStringW &String);
+
+BOOL ShowInstalledAppInfo(INT Index);
+BOOL UninstallApplication(INT Index, BOOL bModify);
+VOID RemoveAppFromRegistry(INT Index);
diff --git a/reactos/base/applications/rapps/include/misc.h b/reactos/base/applications/rapps/include/misc.h
new file mode 100644 (file)
index 0000000..c27007d
--- /dev/null
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <windef.h>
+#include <atlstr.h>
+
+int GetWindowWidth(HWND hwnd);
+int GetWindowHeight(HWND hwnd);
+int GetClientWindowWidth(HWND hwnd);
+int GetClientWindowHeight(HWND hwnd);
+
+VOID CopyTextToClipboard(LPCWSTR lpszText);
+VOID SetWelcomeText(VOID);
+VOID ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem);
+BOOL StartProcess(ATL::CStringW &Path, BOOL Wait);
+BOOL StartProcess(LPWSTR lpPath, BOOL Wait);
+BOOL GetStorageDirectory(ATL::CStringW &lpDirectory);
+BOOL ExtractFilesFromCab(LPCWSTR lpCabName, LPCWSTR lpOutputPath);
+VOID InitLogs(VOID);
+VOID FreeLogs(VOID);
+BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg);
+BOOL GetInstalledVersion(ATL::CStringW *pszVersion, const ATL::CStringW &szRegName);
diff --git a/reactos/base/applications/rapps/include/rapps.h b/reactos/base/applications/rapps/include/rapps.h
new file mode 100644 (file)
index 0000000..09196b1
--- /dev/null
@@ -0,0 +1,14 @@
+#pragma once
+
+#ifndef _RAPPS_H
+#define _RAPPS_H
+
+#include "defines.h"
+
+#include "dialogs.h"
+#include "installed.h"
+#include "available.h"
+#include "misc.h"
+#include "gui.h"
+
+#endif /* _RAPPS_H */
similarity index 99%
rename from reactos/base/applications/rapps/rosui.h
rename to reactos/base/applications/rapps/include/rosui.h
index 2627364..35257df 100644 (file)
@@ -4,6 +4,8 @@
  */
 #pragma once
 
+#include <atlwin.h>
+
 template<class T, int GrowthRate = 10>
 class CPointerArray
 {
diff --git a/reactos/base/applications/rapps/include/winmain.h b/reactos/base/applications/rapps/include/winmain.h
new file mode 100644 (file)
index 0000000..2ecfce4
--- /dev/null
@@ -0,0 +1,35 @@
+#pragma once
+#include <windef.h>
+//TODO: Separate main and settings related definitions
+
+struct SETTINGS_INFO
+{
+    BOOL bSaveWndPos;
+    BOOL bUpdateAtStart;
+    BOOL bLogEnabled;
+    WCHAR szDownloadDir[MAX_PATH];
+    BOOL bDelInstaller;
+    /* Window Pos */
+    BOOL Maximized;
+    INT Left;
+    INT Top;
+    INT Width;
+    INT Height;
+    /* Proxy settings */
+    INT Proxy;
+    WCHAR szProxyServer[MAX_PATH];
+    WCHAR szNoProxyFor[MAX_PATH];
+};
+
+typedef SETTINGS_INFO *PSETTINGS_INFO;
+
+extern HWND hMainWnd;
+extern HINSTANCE hInst;
+extern INT SelectedEnumType;
+extern SETTINGS_INFO SettingsInfo;
+
+VOID SaveSettings(HWND hwnd);
+VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo);
+
+// integrity.cpp 
+BOOL VerifyInteg(LPCWSTR lpSHA1Hash, LPCWSTR lpFileName);
\ No newline at end of file
index d75d24a..b80210d 100644 (file)
@@ -5,8 +5,10 @@
  * PURPOSE:         "Download and Install" Dialog
  * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
  */
+#include "defines.h"
 
-#include "rapps.h"
+#include "dialogs.h"
+#include "available.h"
 
 static PAPPLICATION_INFO AppInfo;
 
@@ -18,7 +20,6 @@ InstallDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
     {
         case WM_INITDIALOG:
         {
-
         }
         break;
 
@@ -47,8 +48,8 @@ InstallApplication(INT Index)
     AppInfo = (PAPPLICATION_INFO) ListViewGetlParam(Index);
     if (!AppInfo) return FALSE;
 
-    DialogBox(hInst,
-              MAKEINTRESOURCE(IDD_INSTALL_DIALOG),
+    DialogBoxW(hInst,
+              MAKEINTRESOURCEW(IDD_INSTALL_DIALOG),
               hMainWnd,
               InstallDlgProc);
 
index 57e6909..dbaf523 100644 (file)
@@ -7,7 +7,12 @@
  *                  Alexander Shaposhnikov      (chaez.san@gmail.com)
  */
 
-#include "rapps.h"
+#include "defines.h"
+
+#include "installed.h"
+
+#include "gui.h"
+#include "misc.h"
 
 BOOL
 GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, ATL::CStringW& String)
@@ -36,62 +41,6 @@ GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR szString)
     return FALSE;
 }
 
-BOOL
-GetInstalledVersion_WowUser(_Out_opt_ ATL::CStringW* szVersionResult, 
-                            _In_z_ const ATL::CStringW& RegName, 
-                            _In_ BOOL IsUserKey, 
-                            _In_ REGSAM keyWow)
-{
-    HKEY hKey;
-    BOOL bHasSucceded = FALSE;
-    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 (szVersionResult != NULL)
-        {
-            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 bHasSucceded;
-}
-
-BOOL GetInstalledVersion(ATL::CStringW* pszVersion, const ATL::CStringW& szRegName)
-{
-    return (!szRegName.IsEmpty()
-            && (::GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY)
-                || ::GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_32KEY)
-                || ::GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_64KEY)
-                || ::GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_64KEY)));
-}
-
 BOOL
 UninstallApplication(INT Index, BOOL bModify)
 {
@@ -147,7 +96,6 @@ UninstallApplication(INT Index, BOOL bModify)
     return StartProcess(szPath, TRUE);
 }
 
-
 BOOL
 ShowInstalledAppInfo(INT Index)
 {
@@ -190,7 +138,6 @@ ShowInstalledAppInfo(INT Index)
     return TRUE;
 }
 
-
 VOID
 RemoveAppFromRegistry(INT Index)
 {
@@ -229,7 +176,6 @@ RemoveAppFromRegistry(INT Index)
     }
 }
 
-
 BOOL
 EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc)
 {
index 72c91fc..18a38cf 100644 (file)
@@ -6,8 +6,8 @@
  * PROGRAMMERS:     Ismael Ferreras Morezuelas (swyterzone+ros@gmail.com)
  *                  Mark Jansen
  */
+#include "defines.h"
 
-#include "rapps.h"
 #include <sha1.h>
 
 BOOL VerifyInteg(const ATL::CStringW &SHA1Hash, const ATL::CStringW &FileName)
index 4da4252..3937f44 100644 (file)
@@ -208,7 +208,7 @@ BEGIN
     IDS_INTEG_CHECK_FAIL "The package did not pass the integrity check, it may have been corrupted or tampered with during downloading. Running the software is not recommended."
     IDS_INTERRUPTED_DOWNLOAD "The download was interrupted. Check connection to Internet."
     IDS_UNABLE_TO_WRITE "Unable to write to disk. Disk may be at capacity."
-    IDS_SELECT_ALL "Select/Desellect All"
+    IDS_SELECT_ALL "Select/Deselect All"
     IDS_INSTALL_SELECTED "Install Selected"
 END
 
index cb47714..a004ad2 100644 (file)
@@ -27,8 +27,7 @@
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
   */
-
-#include "rapps.h"
+#include "defines.h"
 
 #include <shlobj_undoc.h>
 #include <shlguid_undoc.h>
 #include <windowsx.h>
 
 #include "rosui.h"
+#include "dialogs.h"
+
+#ifdef USE_CERT_PINNING
+    #define CERT_ISSUER_INFO "BE\r\nGlobalSign nv-sa\r\nGlobalSign Domain Validation CA - SHA256 - G2"
+    #define CERT_SUBJECT_INFO "Domain Control Validated\r\n*.reactos.org"
+#endif
 
 typedef enum
 {
@@ -834,4 +839,4 @@ VOID CDownloadManager::LaunchDownloadDialog()
                   hMainWnd,
                   DownloadDlgProc);
 }
-// CDownloadManager
\ No newline at end of file
+// CDownloadManager
index 1a26e58..615eb0d 100644 (file)
@@ -7,8 +7,10 @@
  *                  Ismael Ferreras Morezuelas (swyterzone+ros@gmail.com)
  *                  Alexander Shaposhnikov     (chaez.san@gmail.com)
  */
+#include "defines.h"
 
-#include "rapps.h"
+#include "gui.h"
+#include "misc.h"
 
  /* SESSION Operation */
 #define EXTRACT_FILLFILELIST  0x00000001
@@ -26,53 +28,26 @@ typedef struct
 struct FILELIST
 {
     LPSTR FileName;
-    struct FILELIST *next;
+    FILELIST *next;
     BOOL DoExtract;
 };
 
-typedef struct
+struct SESSION
 {
     INT FileSize;
     ERF Error;
-    struct FILELIST *FileList;
+    FILELIST *FileList;
     INT FileCount;
     INT Operation;
     CHAR Destination[MAX_PATH];
     CHAR CurrentFile[MAX_PATH];
     CHAR Reserved[MAX_PATH];
-    struct FILELIST *FilterList;
-} SESSION;
+    FILELIST *FilterList;
+};
 
 typedef HRESULT(WINAPI *fnExtract)(SESSION *dest, LPCSTR szCabName);
 fnExtract pfnExtract;
 
-INT
-GetSystemColorDepth(VOID)
-{
-    DEVMODE pDevMode;
-    INT ColorDepth;
-
-    pDevMode.dmSize = sizeof(pDevMode);
-    pDevMode.dmDriverExtra = 0;
-
-    if (!EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &pDevMode))
-    {
-        /* TODO: Error message */
-        return ILC_COLOR;
-    }
-
-    switch (pDevMode.dmBitsPerPel)
-    {
-    case 32: ColorDepth = ILC_COLOR32; break;
-    case 24: ColorDepth = ILC_COLOR24; break;
-    case 16: ColorDepth = ILC_COLOR16; break;
-    case  8: ColorDepth = ILC_COLOR8;  break;
-    case  4: ColorDepth = ILC_COLOR4;  break;
-    default: ColorDepth = ILC_COLOR;   break;
-    }
-
-    return ColorDepth;
-}
 
 int
 GetWindowWidth(HWND hwnd)
@@ -396,5 +371,58 @@ 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)
+{
+    HKEY hKey;
+    BOOL bHasSucceded = FALSE;
+    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 (szVersionResult != NULL)
+        {
+            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 bHasSucceded;
+}
 
+BOOL GetInstalledVersion(ATL::CStringW * pszVersion, const ATL::CStringW & szRegName)
+{
+    return (!szRegName.IsEmpty()
+            && (GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY)
+                || GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_32KEY)
+                || GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_64KEY)
+                || GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_64KEY)));
+}
diff --git a/reactos/base/applications/rapps/rapps.h b/reactos/base/applications/rapps/rapps.h
deleted file mode 100644 (file)
index d187658..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-#pragma once
-
-#ifndef _RAPPS_H
-#define _RAPPS_H
-
-#include <tchar.h>
-#include <stdarg.h>
-
-#define WIN32_NO_STATUS
-#define _INC_WINDOWS
-#define COM_NO_WINDOWS_H
-#define COBJMACROS
-
-#include <windef.h>
-#include <winbase.h>
-#include <winreg.h>
-#include <wingdi.h>
-#include <winnls.h>
-#include <winuser.h>
-#include <wincon.h>
-#include <richedit.h>
-#include <shellapi.h>
-#include <shlobj.h>
-#include <shlwapi.h>
-#include <stdio.h>
-#include <strsafe.h>
-#include <ndk/rtlfuncs.h>
-#include <atlcoll.h>
-#include <atlsimpcoll.h>
-#include <atlstr.h> 
-#include <rappsmsg.h>
-
-#include "resource.h"
-
-#ifdef USE_CERT_PINNING
-  #define CERT_ISSUER_INFO "BE\r\nGlobalSign nv-sa\r\nGlobalSign Domain Validation CA - SHA256 - G2"
-  #define CERT_SUBJECT_INFO "Domain Control Validated\r\n*.reactos.org"
-#endif
-
-#define APPLICATION_DATABASE_URL L"https://svn.reactos.org/packages/rappmgr.cab"
-
-#define SPLIT_WIDTH 4
-#define MAX_STR_LEN 256
-#define LISTVIEW_ICON_SIZE 24
-#define TREEVIEW_ICON_SIZE 24
-
-/* EnumType flags for EnumInstalledApplications */
-#define ENUM_ALL_COMPONENTS    30
-#define ENUM_APPLICATIONS      31
-#define ENUM_UPDATES           32
-/* EnumType flags for EnumAvailableApplications */
-#define ENUM_ALL_AVAILABLE     0
-#define ENUM_CAT_AUDIO         1
-#define ENUM_CAT_VIDEO         2
-#define ENUM_CAT_GRAPHICS      3
-#define ENUM_CAT_GAMES         4
-#define ENUM_CAT_INTERNET      5
-#define ENUM_CAT_OFFICE        6
-#define ENUM_CAT_DEVEL         7
-#define ENUM_CAT_EDU           8
-#define ENUM_CAT_ENGINEER      9
-#define ENUM_CAT_FINANCE       10
-#define ENUM_CAT_SCIENCE       11
-#define ENUM_CAT_TOOLS         12
-#define ENUM_CAT_DRIVERS       13
-#define ENUM_CAT_LIBS          14
-#define ENUM_CAT_OTHER         15
-
-#define ENUM_INSTALLED_MIN ENUM_ALL_COMPONENTS
-#define ENUM_INSTALLED_MAX ENUM_UPDATES
-#define ENUM_AVAILABLE_MIN ENUM_ALL_AVAILABLE
-#define ENUM_AVAILABLE_MAX ENUM_CAT_OTHER
-
-#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)
-
-typedef enum
-{
-    None,
-    OpenSource,
-    Freeware,
-    Trial,
-    Max = Trial,
-    Min = None
-} LICENSE_TYPE, *PLICENSE_TYPE;
-
-/* aboutdlg.cpp */
-VOID ShowAboutDialog(VOID);
-
-/* available.cpp */
-typedef struct
-{
-    INT Category;
-    LICENSE_TYPE LicenseType;
-    ATL::CStringW szName;
-    ATL::CStringW szRegName;
-    ATL::CStringW szVersion;
-    ATL::CStringW szLicense;
-    ATL::CStringW szDesc;
-    ATL::CStringW szSize;
-    ATL::CStringW szUrlSite;
-    ATL::CStringW szUrlDownload;
-    ATL::CStringW szCDPath;
-    ATL::CSimpleArray<LCID> Languages;
-
-    /* caching mechanism related entries */
-    ATL::CStringW sFileName;
-    FILETIME ftCacheStamp;
-
-    /* optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form) */
-    ATL::CStringW szSHA1;
-
-} APPLICATION_INFO, *PAPPLICATION_INFO;
-
-extern ATL::CAtlList<PAPPLICATION_INFO> InfoList;
-
-typedef struct
-{
-    HKEY hRootKey;
-    HKEY hSubKey;
-    ATL::CStringW szKeyName;
-
-} INSTALLED_INFO, *PINSTALLED_INFO;
-
-typedef struct
-{
-    BOOL bSaveWndPos;
-    BOOL bUpdateAtStart;
-    BOOL bLogEnabled;
-    WCHAR szDownloadDir[MAX_PATH];
-    BOOL bDelInstaller;
-    /* Window Pos */
-    BOOL Maximized;
-    INT Left;
-    INT Top;
-    INT Width;
-    INT Height;
-    /* Proxy settings */
-    INT Proxy;
-    WCHAR szProxyServer[MAX_PATH];
-    WCHAR szNoProxyFor[MAX_PATH];
-
-} SETTINGS_INFO, *PSETTINGS_INFO;
-
-/* available.cpp */
-class CConfigParser
-{
-    // Loacale names cache
-    static ATL::CStringW m_szLocaleID;
-    const static INT m_cchLocaleSize = 5;
-    static ATL::CStringW m_szCachedINISectionLocale;
-    static ATL::CStringW m_szCachedINISectionLocaleNeutral;
-
-    const LPCWSTR STR_VERSION_CURRENT = L"CURRENT";
-    const ATL::CStringW szConfigPath;
-
-    static ATL::CStringW GetINIFullPath(const ATL::CStringW& FileName);
-    static VOID CacheINILocaleLazy();
-
-public:
-    static const ATL::CStringW& GetLocale();
-    static INT CConfigParser::GetLocaleSize();
-
-    CConfigParser(const ATL::CStringW& FileName);
-
-    UINT GetString(const ATL::CStringW& KeyName, ATL::CStringW& ResultString);
-    UINT GetInt(const ATL::CStringW& KeyName);
-};
-
-typedef BOOL (CALLBACK *AVAILENUMPROC)(PAPPLICATION_INFO Info, LPCWSTR szFolderPath);
-struct CAvailableApplicationInfo : public APPLICATION_INFO
-{
-    ATL::CStringW szInstalledVersion;
-    CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam);
-
-    // Load all info from the file
-    VOID RefreshAppInfo();
-    BOOL HasLanguageInfo() const;
-    BOOL HasNativeLanguage() const;
-    BOOL HasEnglishLanguage() const;
-    BOOL IsInstalled() const;
-    BOOL HasInstalledVersion() const;
-    BOOL HasUpdate() const;
-
-    // Set a timestamp
-    VOID SetLastWriteTime(FILETIME* ftTime);
-
-private:
-    BOOL m_IsInstalled = FALSE;
-    BOOL m_HasLanguageInfo = FALSE;
-    BOOL m_HasInstalledVersion = FALSE;
-    CConfigParser m_Parser;
-
-    inline BOOL GetString(LPCWSTR lpKeyName, 
-                          ATL::CStringW& ReturnedString);
-
-    // Lazily load general info from the file
-    VOID RetrieveGeneralInfo();
-    VOID RetrieveInstalledStatus();
-    VOID RetrieveInstalledVersion();
-    VOID RetrieveLanguages();
-    VOID RetrieveLicenseType();
-    inline BOOL FindInLanguages(LCID what) const;
-};
-
-class CAvailableApps
-{
-    ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
-    ATL::CStringW m_szPath;
-    ATL::CStringW m_szCabPath;
-    ATL::CStringW m_szAppsPath;
-    ATL::CStringW m_szSearchPath;
-
-public:
-    CAvailableApps();
-    VOID FreeCachedEntries();
-    BOOL DeleteCurrentAppsDB();
-    BOOL UpdateAppsDB();
-    BOOL EnumAvailableApplications(INT EnumType, AVAILENUMPROC lpEnumProc);
-    const ATL::CStringW& GetFolderPath();
-    const ATL::CStringW& GetAppPath();
-    const ATL::CStringW& GetCabPath();
-    const LPCWSTR GetFolderPathString();
-    const LPCWSTR GetAppPathString();
-    const LPCWSTR GetCabPathString();
-};
-
-/* installdlg.cpp */
-//BOOL InstallApplication(INT Index);
-
-/* installed.cpp */
-typedef BOOL (CALLBACK *APPENUMPROC)(INT ItemIndex, ATL::CStringW &lpName, PINSTALLED_INFO Info);
-BOOL EnumInstalledApplications(INT EnumType, BOOL IsUserKey, APPENUMPROC lpEnumProc);
-BOOL GetApplicationString(HKEY hKey, LPCWSTR lpKeyName, LPWSTR szString);
-BOOL GetApplicationString(HKEY hKey, LPCWSTR RegName, ATL::CStringW& String);
-
-BOOL ShowInstalledAppInfo(INT Index);
-BOOL UninstallApplication(INT Index, BOOL bModify);
-VOID RemoveAppFromRegistry(INT Index);
-
-BOOL GetInstalledVersion(ATL::CStringW* pszVersion, const ATL::CStringW& szRegName);
-
-/* winmain.cpp */
-extern HWND hMainWnd;
-extern HINSTANCE hInst;
-extern INT SelectedEnumType;
-extern SETTINGS_INFO SettingsInfo;
-VOID SaveSettings(HWND hwnd);
-VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo);
-
-/* loaddlg.cpp */
-class CDowloadingAppsListView;
-
-class CDownloadManager
-{
-    static PAPPLICATION_INFO AppInfo;
-    static ATL::CSimpleArray<PAPPLICATION_INFO> AppsToInstallList;
-    static CDowloadingAppsListView DownloadsListView;
-    static INT iCurrentApp;
-public:
-    static INT_PTR CALLBACK DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
-    static LRESULT CALLBACK DownloadProgressProc(HWND hWnd, 
-                                                 UINT uMsg, 
-                                                 WPARAM wParam, 
-                                                 LPARAM lParam, 
-                                                 UINT_PTR uIdSubclass, 
-                                                 DWORD_PTR dwRefData);
-
-    static DWORD WINAPI ThreadFunc(LPVOID Context);
-    static BOOL DownloadListOfApplications(const ATL::CSimpleArray<PAPPLICATION_INFO>& AppsList);
-    static BOOL DownloadApplication(PAPPLICATION_INFO pAppInfo);
-    static VOID DownloadApplicationsDB(LPCWSTR lpUrl);
-    static VOID LaunchDownloadDialog();
-};
-
-/* misc.cpp */
-INT GetSystemColorDepth(VOID);
-int GetWindowWidth(HWND hwnd);
-int GetWindowHeight(HWND hwnd);
-int GetClientWindowWidth(HWND hwnd);
-int GetClientWindowHeight(HWND hwnd);
-VOID CopyTextToClipboard(LPCWSTR lpszText);
-VOID SetWelcomeText(VOID);
-VOID ShowPopupMenu(HWND hwnd, UINT MenuID, UINT DefaultItem);
-BOOL StartProcess(ATL::CStringW & Path, BOOL Wait);
-BOOL StartProcess(LPWSTR lpPath, BOOL Wait);
-BOOL GetStorageDirectory(ATL::CStringW &lpDirectory);
-BOOL ExtractFilesFromCab(LPCWSTR lpCabName, LPCWSTR lpOutputPath);
-VOID InitLogs(VOID);
-VOID FreeLogs(VOID);
-BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg);
-
-/* settingsdlg.cpp */
-VOID CreateSettingsDlg(HWND hwnd);
-
-/* gui.cpp */
-HWND CreateMainWindow();
-DWORD_PTR ListViewGetlParam(INT item);
-INT ListViewAddItem(INT ItemIndex, INT IconIndex, LPWSTR lpName, LPARAM lParam);
-VOID SetStatusBarText(LPCWSTR szText);
-VOID NewRichEditText(LPCWSTR szText, DWORD flags);
-VOID InsertRichEditText(LPCWSTR szText, DWORD flags);
-
-VOID SetStatusBarText(const ATL::CStringW& szText);
-INT ListViewAddItem(INT ItemIndex, INT IconIndex, ATL::CStringW & Name, LPARAM lParam);
-VOID NewRichEditText(const ATL::CStringW& szText, DWORD flags);
-VOID InsertRichEditText(const ATL::CStringW& szText, DWORD flags);
-CAvailableApps * GetAvailableApps();
-extern HWND hListView;
-extern ATL::CStringW szSearchPattern;
-
-/* integrity.cpp */
-BOOL VerifyInteg(LPCWSTR lpSHA1Hash, LPCWSTR lpFileName);
-
-//extern HWND hTreeView;
-//BOOL CreateTreeView(HWND hwnd);
-//HTREEITEM TreeViewAddItem(HTREEITEM hParent, LPWSTR lpText, INT Image, INT SelectedImage, LPARAM lParam);
-
-#endif /* _RAPPS_H */
index ea13f9c..13b5a0d 100644 (file)
@@ -6,8 +6,9 @@
  * PROGRAMMERS:     Dmitry Chapyshev           (dmitry@reactos.org)
  *                  Alexander Shaposhnikov     (chaez.san@gmail.com)
  */
+#include "defines.h"
 
-#include "rapps.h"
+#include "dialogs.h"
 
 SETTINGS_INFO NewSettingsInfo;
 
index a24e5cf..f848247 100644 (file)
@@ -7,6 +7,7 @@
  *                  Ismael Ferreras Morezuelas (swyterzone+ros@gmail.com)
  *                  Alexander Shaposhnikov     (chaez.san@gmail.com)
  */
+#include "defines.h"
 
 #include "rapps.h"
 
@@ -188,10 +189,10 @@ wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nSh
         GetAvailableApps()->UpdateAppsDB();
 
     /* Load the menu hotkeys */
-    KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCE(HOTKEYS));
+    KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCEW(HOTKEYS));
 
     /* Message Loop */
-    while (GetMessage(&Msg, NULL, 0, 0))
+    while (GetMessageW(&Msg, NULL, 0, 0))
     {
         if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
         {