1 /* 2 * PROJECT: ReactOS Applications Manager 3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later) 4 * PURPOSE: Main program 5 * COPYRIGHT: Copyright 2009 Dmitry Chapyshev (dmitry@reactos.org) 6 * Copyright 2015 Ismael Ferreras Morezuelas (swyterzone+ros@gmail.com) 7 * Copyright 2017 Alexander Shaposhnikov (sanchaez@reactos.org) 8 */ 9 #include "rapps.h" 10 11 #include "unattended.h" 12 13 #include "winmain.h" 14 15 #include <atlcom.h> 16 17 #include <gdiplus.h> 18 19 #include <conutils.h> 20 21 LPCWSTR szWindowClass = L"ROSAPPMGR"; 22 23 HWND hMainWnd; 24 HINSTANCE hInst; 25 SETTINGS_INFO SettingsInfo; 26 27 class CRAppsModule : public CComModule 28 { 29 public: 30 }; 31 32 BEGIN_OBJECT_MAP(ObjectMap) 33 END_OBJECT_MAP() 34 35 CRAppsModule gModule; 36 CAtlWinModule gWinModule; 37 38 Gdiplus::GdiplusStartupInput gdiplusStartupInput; 39 ULONG_PTR gdiplusToken; 40 41 42 static VOID InitializeAtlModule(HINSTANCE hInstance, BOOL bInitialize) 43 { 44 if (bInitialize) 45 { 46 gModule.Init(ObjectMap, hInstance, NULL); 47 } 48 else 49 { 50 gModule.Term(); 51 } 52 } 53 54 VOID InitializeGDIPlus(BOOL bInitialize) 55 { 56 if (bInitialize) 57 { 58 Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); 59 } 60 else 61 { 62 Gdiplus::GdiplusShutdown(gdiplusToken); 63 } 64 } 65 66 int wmain(int argc, wchar_t *argv[]) 67 { 68 BOOL bIsFirstLaunch; 69 70 InitializeAtlModule(GetModuleHandle(NULL), TRUE); 71 InitializeGDIPlus(TRUE); 72 73 if (GetUserDefaultUILanguage() == MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT)) 74 { 75 SetProcessDefaultLayout(LAYOUT_RTL); 76 } 77 78 hInst = GetModuleHandle(NULL); 79 80 bIsFirstLaunch = !LoadSettings(&SettingsInfo); 81 if (bIsFirstLaunch) 82 { 83 FillDefaultSettings(&SettingsInfo); 84 } 85 86 InitLogs(); 87 InitCommonControls(); 88 89 // parse cmd-line and perform the corresponding operation 90 BOOL bSuccess = ParseCmdAndExecute(GetCommandLineW(), bIsFirstLaunch, SW_SHOWNORMAL); 91 92 InitializeGDIPlus(FALSE); 93 InitializeAtlModule(GetModuleHandle(NULL), FALSE); 94 95 return bSuccess ? 0 : 1; 96 } 97