fsODMenuItemData* fsODMenu::AttachMenuItem(CMenu *pMenu, UINT iPos, BOOL bByPos)
{
	fsODMenuItemData *pData;
	
	fsnew1 (pData, fsODMenuItemData);

	UINT nByPosFl = bByPos ? MF_BYPOSITION : MF_BYCOMMAND;

	UINT uState = pMenu->GetMenuState (iPos, nByPosFl);

	UINT nID;
	
	if (uState & MF_POPUP)
		nID = (UINT) pMenu->GetSubMenu (iPos)->m_hMenu;
	else if (bByPos)
		nID = pMenu->GetMenuItemID (iPos);
	else
		nID = iPos;

	pMenu->GetMenuString (iPos, pData->strMenuText, nByPosFl);

	if (uState & MF_POPUP)  
		uState = MF_POPUP;

	
	pMenu->ModifyMenu (iPos, uState | MF_OWNERDRAW | nByPosFl, nID, (LPCSTR)pData);

	pData->iImage = pData->iCheckImage = -1;
	pData->bBold = pData->bMenuBar = FALSE;

	return pData;	
}
Exemple #2
0
fsWebPageDownloader* CSpiderWnd::AddWebPage(LPCSTR pszStartUrl, BOOL bReqTopMost)
{
	fsWebPageDownloader *wpd;
	fsnew1 (wpd, fsWebPageDownloader);

	CSpiderAddPageDlg dlg;
	dlg.m_wpd = wpd;
	if (pszStartUrl)
		dlg.m_strStartUrl = pszStartUrl;
	else
		dlg.m_strStartUrl = "";

	dlg.m_bReqTopMost = bReqTopMost;

	if (_DlgMgr.DoModal (&dlg) == IDCANCEL)
	{
		delete wpd;
		return NULL;
	}

	m_mgr.Add (wpd);

	if (wpd->Create (dlg.m_strUrl, dlg.m_bAutoStart, dlg.m_bScheduled ? &dlg.m_task : NULL) == FALSE)
		m_mgr.Delete (wpd);
	else
		m_wndTasks.AddWebPage (wpd);

	return wpd;
}
Exemple #3
0
HWND CSitesWnd::Plugin_CreateMainWindow(HWND hWndParent)
{
	fsnew1 (_pwndSites, CSitesWnd);

	_pwndSites->Create (CWnd::FromHandle (hWndParent));

	return _pwndSites->m_hWnd;
}
Exemple #4
0
HWND CUploadsWnd::Plugin_CreateMainWindow(HWND hWndParent)
{
	fsnew1 (_pwndUploads, CUploadsWnd);

	_pwndUploads->Create (CWnd::FromHandle (hWndParent));

	return _pwndUploads ? _pwndUploads->m_hWnd : NULL;
}
Exemple #5
0
HWND CSpiderWnd::Plugin_CreateMainWindow(HWND hParent)
{
	fsnew1 (_pwndSpider, CSpiderWnd);

	_pwndSpider->Create (CWnd::FromHandle (hParent));

	return _pwndSpider->m_hWnd;
}
HWND CFlashVideoDownloadsWnd::Plugin_CreateMainWindow(HWND hWndParent)
{
	fsnew1 (_pwndFVDownloads, CFlashVideoDownloadsWnd);

	_pwndFVDownloads->Create (CWnd::FromHandle (hWndParent));

	return _pwndFVDownloads->m_hWnd;
}
Exemple #7
0
void fsUpdateMgr::Update(BOOL bByFull)
{
	if (m_bRunning == FALSE || m_bChecking)
		return;

	SAFE_DELETE (m_dldr);
	fsnew1 (m_dldr, fsDownloadMgr (NULL));
	m_dldr->SetEventFunc (_DownloadMgrEvents, this);
	m_dldr->SetEventDescFunc (_DownloadMgrDescEvents, this);

	m_bChecking = FALSE;

	CString strUrl;	
	if (bByFull)
		strUrl.Format (_T("%sfdminst.exe"), m_strDlFullInstallPath);
	else
	{
		
		if (m_strUpgFileName.GetLength () == 0)
			
			strUrl.Format (_T("%sfdm%sto%supg.exe"), m_strDlUpgradesPath, vmsFdmAppMgr::getBuildNumberAsString (), m_strBN);
		else
			
			strUrl.Format (_T("%s%s"), m_strDlUpgradesPath, m_strUpgFileName);
	}

	m_dldr->CreateByUrl (strUrl);
	
	fsDownload_Properties *dp = m_dldr->GetDP ();
	fsDownload_NetworkProperties *dnp = m_dldr->GetDNP ();

	SAFE_DELETE_ARRAY (dp->pszFileName);
	CString strFile = fsGetDataFilePath (_T("Update\\"));
	fsnew (dp->pszFileName, TCHAR, strFile.GetLength () + 1);
	_tcscpy (dp->pszFileName, strFile);
	dp->enAER = AER_REWRITE;
	dp->uMaxAttempts = 1;
	*dp->pszAdditionalExt = 0;

	dnp->dwFlags &= ~DNPF_RESTARTSECTIONWHENSPEEDTOOLOW;

	Event (UME_CONNECTING);

	m_dldr->StartDownloading ();
}
Exemple #8
0
void fsUpdateMgr::CheckForUpdate(bool bByUser)
{
	if (m_bRunning || IS_PORTABLE_MODE)
		return;

	m_bCheckingByUser = bByUser;

	SAFE_DELETE (m_dldr);
	fsnew1 (m_dldr, fsDownloadMgr (NULL));
	m_dldr->SetEventFunc (_DownloadMgrEvents, this);
	m_dldr->SetEventDescFunc (_DownloadMgrDescEvents, this);
	
	m_bRunning = TRUE;
	m_bChecking = TRUE;

	CMainFrame* pFrm = (CMainFrame*) AfxGetApp ()->m_pMainWnd;

	CString strUrl = m_strUpdateUrl;

	strUrl += _T("proupd3.lst");

	if (!_App.Update_CheckedOnce ())
		strUrl += _T ("?initial");

	std::wstring Customizer = pFrm->get_Customizations ()->get_Customizer () ? 
		wideFromUtf8 (pFrm->get_Customizations ()->get_Customizer ()) : 
		L"";
	if (!Customizer.empty ())
	{
		strUrl += _T("?edition=");
		strUrl += Customizer.c_str ();
	}

	m_dldr->CreateByUrl (strUrl);
	
	fsDownload_Properties *dp = m_dldr->GetDP ();
	fsDownload_NetworkProperties *dnp = m_dldr->GetDNP ();

	SAFE_DELETE_ARRAY (dp->pszFileName);
	CString strFile = fsGetDataFilePath (_T("Update\\"));	
	fsnew (dp->pszFileName, TCHAR, strFile.GetLength () + 1);
	_tcscpy (dp->pszFileName, strFile);
	dp->uMaxSections = 1;
	dp->uMaxAttempts = 1;
	dp->dwFlags |= DPF_DONTRESTARTIFNORESUME | DPF_FORCE_NO_RECOVERY;
	dp->enSCR = SCR_STOP;
	dp->enAER = AER_REWRITE;
	*dp->pszAdditionalExt = 0;

	SAFE_DELETE_ARRAY (dnp->pszReferer);

	fsnew (dnp->pszReferer, TCHAR, 100);
	_stprintf (dnp->pszReferer, _T("fdm:version:%s"), 
		vmsFdmAppMgr::getVersion ()->m_fileVersion.ToString ().c_str ());

	dnp->dwFlags &= ~DNPF_RESTARTSECTIONWHENSPEEDTOOLOW;

	Event (UME_CONNECTING);

	m_dldr->StartDownloading ();
}
DWORD WINAPI fsInternetFileListMgr::_threadGetList(LPVOID lp)
{
	fsInternetFileListMgr* pThis = (fsInternetFileListMgr*) lp;

	CString strProxy, strPUser, strPPassword;
	fsURL url;

	if (url.Crack (pThis->_strUrl) != IR_SUCCESS)
	{
		pThis->m_lastError = IR_BADURL;
		goto _lExit;
	}

	if (*url.GetHostName () == 0 || *url.GetPath () == 0)
	{
		pThis->m_lastError = IR_BADURL;
		goto _lExit;
	}

	if (*url.GetUserName ())
	{
		if (pThis->m_strUser != url.GetUserName ())
		{
			pThis->m_strUser = url.GetUserName ();
			pThis->m_strPassword = url.GetPassword ();
			pThis->Free (FALSE);
			pThis->m_bConnected = FALSE;
		}
	}
	else
	{
		if (pThis->m_strUser != pThis->_strUser)
		{
			if (pThis->_strUser != NULL || fsIsServersEqual (url.GetHostName (), pThis->m_server.GetServerName ()) == FALSE)
			{
				pThis->m_strUser = pThis->_strUser;
				pThis->m_strPassword = pThis->_strPassword;
				pThis->m_bConnected = FALSE;
			}
		}
	}

	pThis->m_bCurPathIsRoot = strcmp (url.GetPath (), "/") == 0 || strcmp (url.GetPath (), "\\") == 0;

_lConnect:

	
	
	if (pThis->m_bConnected == FALSE ||
		 FALSE == fsIsServersEqual (pThis->m_server.GetServerName (), url.GetHostName ()) ||
		 pThis->m_server.GetScheme () != url.GetInternetScheme () )
	{
		pThis->Free (FALSE);

		

		fsGetProxy (fsSchemeToNP (url.GetInternetScheme ()), strProxy, strPUser, strPPassword);

		pThis->m_session.Create (_App.Agent (), _App.InternetAccessType (), strProxy,
			fsSchemeToNP (url.GetInternetScheme ()));
		pThis->m_session.SetProxyAuth (strPUser, strPPassword);
		pThis->m_session.SetTimeout (_App.Timeout ());
		pThis->m_server.Initialize (&pThis->m_session);
		pThis->m_server.UseFtpPassiveMode (pThis->m_bFtpPassiveMode);

		UINT cAttempts = _App.MaxAttempts ();

		do
		{
			pThis->Event (FLME_CONNECTING);

			
			
			pThis->m_lastError = pThis->m_server.Connect (pThis->_strUrl, pThis->m_strUser, pThis->m_strPassword, url.GetPort ());
			if (pThis->m_lastError != IR_SUCCESS)
			{
				if (pThis->m_lastError != IR_S_FALSE)
					pThis->Event (FLME_ERROR);
			}
			else
			{
				
				if (pThis->m_server.IsFtpServer ())
					pThis->Event (FLME_CONNECTED);
			}

			if (pThis->m_lastError != IR_SUCCESS)
			{
				if (pThis->m_lastError == IR_LOGINFAILURE || pThis->m_lastError == IR_INVALIDUSERNAME ||
					 pThis->m_lastError == IR_INVALIDPASSWORD)
				{
					

					fsSiteInfo *site = _SitesMgr.FindSite2 (url.GetHostName (), fsNPToSiteValidFor (fsSchemeToNP (url.GetInternetScheme ())));
					if (site && site->strUser)
					{
						CString strPass = site->strPassword ? site->strPassword : "";
						if (site->strUser != pThis->m_strUser || strPass != pThis->m_strPassword)
						{
							

							pThis->Event (FLME_TRYINGTOUSESITEMGRLOGIN);
							pThis->m_strUser = site->strUser;
							pThis->m_strPassword = strPass;
							continue;
						}
					}

					

					if (pThis->AskForLogin (url.GetHostName ()))
						continue;
					else
						break;
				}

				pThis->SleepInterval ();
			}

			cAttempts--;

			if (cAttempts == 0)
				break;
		}
		while (pThis->m_lastError != IR_SUCCESS && pThis->m_bAbort == FALSE);

		if (pThis->m_lastError == IR_SUCCESS && pThis->m_bAbort == FALSE)
		{
			if (pThis->m_server.IsFtpServer ())
			{
				pThis->m_bConnected = TRUE;
			}
		}
		else
		{
			pThis->Event (FLME_STOPPED);
			goto _lExit2;
		}
	}
	else if (pThis->m_server.IsFtpServer () == FALSE)
		pThis->Event (FLME_CONNECTING);

	UINT cAttempts;
	cAttempts = _App.MaxAttempts ();

	do
	{
		
		if (pThis->m_server.IsFtpServer ())
			pThis->Event (FLME_GETTINGLIST);

		fsnew1 (pThis->m_files, fsInternetURLFiles);
		pThis->m_files->SetHttpEventFunc (_HttpEvents, pThis);
		pThis->m_files->RetreiveInfoWhileGettingList (pThis->m_bRetreiveInfoWhileGettingList);
		
		pThis->m_lastError = pThis->m_files->GetList (&pThis->m_server, url.GetPath ());

		if (pThis->m_lastError == IR_S_REDIRECTED)
			pThis->m_lastError = IR_SUCCESS;
	
		if (pThis->m_lastError != IR_SUCCESS && pThis->m_lastError != IR_S_REDIRECTED)
		{
			fsInternetURLFiles *files = pThis->m_files;
			pThis->m_files = NULL;
			delete files;

			if (pThis->m_lastError != IR_S_FALSE)
				pThis->Event (FLME_ERROR);

			if (pThis->m_bAbort)
				break;

			switch (pThis->m_lastError)
			{
				case IR_CONNECTIONABORTED:
				case IR_LOSTCONNECTION:
					pThis->Event (FLME_CONNECTIONWASLOST_RESTORE);
					pThis->m_bConnected = FALSE;
					goto _lConnect;
				break;

				case IR_LOGINFAILURE:
				case IR_INVALIDUSERNAME:
				case IR_INVALIDPASSWORD:
					if (pThis->AskForLogin (url.GetHostName ()))
						goto _lConnect;
					else
					{
						pThis->Event (FLME_STOPPED);
						goto _lExit2;
					}
				break;
			}

			cAttempts--;

			if (cAttempts == 0 || pThis->m_bAbort)
				break;

			pThis->SleepInterval ();

			if (pThis->m_bAbort == FALSE)
				pThis->Event (FLME_CONNECTING);
		}
	}
	while (pThis->m_lastError != IR_SUCCESS && pThis->m_bAbort == FALSE);

	pThis->_strUrl = NULL;

	if (pThis->m_lastError == IR_SUCCESS)
		pThis->m_vFiles.add (pThis->m_files);
	else
	{
		pThis->Event (FLME_STOPPED);
		goto _lExit2;
	}

_lExit:

	if (pThis->m_lastError != IR_SUCCESS)
	{
		if (pThis->m_lastError != IR_S_FALSE)
			pThis->Event (FLME_ERROR);
	}
	else
		pThis->Event (FLME_DONE);

_lExit2:
	
	pThis->m_bThread = FALSE;

	return 0;
}
BOOL fsPluginMgr::LoadBuiltIn()
{
    fsPluginInfo plug;

    plug.hLib = NULL;

    m_images.Create (_TB_SIZE_X, _TB_SIZE_Y, ILC_COLOR32 | ILC_MASK, 5, 1);




    fntGetMainMenu afnGMM [] = {
        CDownloadsWnd::Plugin_GetMainMenu,
        CFlashVideoDownloadsWnd::Plugin_GetMainMenu,
        CTorrentsWnd::Plugin_GetMainMenu,

        CShedulerWnd::Plugin_GetMainMenu,
        CHFEWnd::Plugin_GetMainMenu,
        CSitesWnd::Plugin_GetMainMenu,
        CSpiderWnd::Plugin_GetMainMenu,
    };
    fntGetViewMenu afnGVM [] = {
        CDownloadsWnd::Plugin_GetViewMenu,
        CFlashVideoDownloadsWnd::Plugin_GetViewMenu,
        CTorrentsWnd::Plugin_GetViewMenu,

        CShedulerWnd::Plugin_GetViewMenu,
        CHFEWnd::Plugin_GetViewMenu,
        CSitesWnd::Plugin_GetViewMenu,
        CSpiderWnd::Plugin_GetViewMenu,
    };


    const int cPlugins = sizeof (afnGMM) / sizeof (fntGetMainMenu);


    fntCreateMainWindow afnCMW [] = {
        CDownloadsWnd::Plugin_CreateMainWindow,
        CFlashVideoDownloadsWnd::Plugin_CreateMainWindow,
        CTorrentsWnd::Plugin_CreateMainWindow,

        CShedulerWnd::Plugin_CreateMainWindow,
        CHFEWnd::Plugin_CreateMainWindow,
        CSitesWnd::Plugin_CreateMainWindow,
        CSpiderWnd::Plugin_CreateMainWindow
    };

    fntGetPluginNames afnGPN [] = {
        CDownloadsWnd::Plugin_GetPluginNames,
        CFlashVideoDownloadsWnd::Plugin_GetPluginNames,
        CTorrentsWnd::Plugin_GetPluginNames,

        CShedulerWnd::Plugin_GetPluginNames,
        CHFEWnd::Plugin_GetPluginNames,
        CSitesWnd::Plugin_GetPluginNames,
        CSpiderWnd::Plugin_GetPluginNames
    };

    fntSetLanguage afnSL [] = {
        CDownloadsWnd::Plugin_SetLanguage,
        CFlashVideoDownloadsWnd::Plugin_SetLanguage,
        CTorrentsWnd::Plugin_SetLanguage,

        CShedulerWnd::Plugin_SetLanguage,
        CHFEWnd::Plugin_SetLanguage,
        CSitesWnd::Plugin_SetLanguage,
        CSpiderWnd::Plugin_SetLanguage
    };

    UINT aIDBmps [] = {
        IDB_TOOL_DLDS, IDB_TOOL_DLDS, IDB_TOOL_BT,
        IDB_TOOL_SCHEDULE, IDB_TOOL_HFE,
        IDB_TOOL_SITES, IDB_TOOL_SPIDER
    };
    UINT aIDBmpsD [] = {
        IDB_TOOL_DLDS_D, IDB_TOOL_DLDS_D, IDB_TOOL_BT_D,
        IDB_TOOL_SCHEDULE_D, IDB_TOOL_HFE_D,
        IDB_TOOL_SITES_D, IDB_TOOL_SPIDER_D
    };

    fntGetMenuImages afnGMI [] = {
        CDownloadsWnd::Plugin_GetMenuImages,
        CFlashVideoDownloadsWnd::Plugin_GetMenuImages,
        CTorrentsWnd::Plugin_GetMenuImages,

        CShedulerWnd::Plugin_GetMenuImages,
        CHFEWnd::Plugin_GetMenuImages,
        CSitesWnd::Plugin_GetMenuImages,
        CSpiderWnd::Plugin_GetMenuImages
    };

    fntGetTBInfo afnGTBI [] = {
        CDownloadsWnd::Plugin_GetToolBarInfo,
        CFlashVideoDownloadsWnd::Plugin_GetToolBarInfo,
        CTorrentsWnd::Plugin_GetToolBarInfo,

        CShedulerWnd::Plugin_GetToolBarInfo,
        CHFEWnd::Plugin_GetToolBarInfo,
        CSitesWnd::Plugin_GetToolBarInfo,
        CSpiderWnd::Plugin_GetToolBarInfo
    };

    fntGetMenuViewItems afnGMVI [] = {
        CDownloadsWnd::Plugin_GetMenuViewItems,
        CFlashVideoDownloadsWnd::Plugin_GetMenuViewItems,
        CTorrentsWnd::Plugin_GetMenuViewItems,

        CShedulerWnd::Plugin_GetMenuViewItems,
        CHFEWnd::Plugin_GetMenuViewItems,
        CSitesWnd::Plugin_GetMenuViewItems,
        CSpiderWnd::Plugin_GetMenuViewItems
    };


    for (int i = 0; i < cPlugins; i++)
    {
        LPCSTR pszPlug, psz;
        afnGPN [i] (&psz, &pszPlug);



        plug.hWnd = afnCMW [i] (m_pPluginsFrame->m_hWnd);
        if (plug.hWnd == NULL)
        {
            if (i == 0)
                return FALSE;
            continue;
        }


        plug.hMenuMain = afnGMM [i] ();
        plug.hMenuView = afnGVM [i] ();



        fsnew1 (plug.pbmpMenuImages, CBitmap);
        plug.pbmpMenuImages->Attach (SBMP (aIDBmps [i]));
        fsnew1 (plug.pbmpMenuDImages, CBitmap);
        plug.pbmpMenuDImages->Attach (SBMP (aIDBmpsD [i]));


        afnGMI [i] (&plug.pMenuMainImages, &plug.cMenuMainImages);
        plug.pMenuViewImages = NULL;
        plug.cMenuViewImages = 0;


        plug.pfnGPN = afnGPN [i];
        plug.pfnGTBI = afnGTBI [i];
        plug.pfnGMVI = afnGMVI [i];
        plug.pfnSetLanguage = afnSL [i];
        plug.pfnRTS = NULL;
        plug.pfnShutdown = NULL;


        afnGMVI [i] (&plug.pMenuViewItems, &plug.cMenuViewItems);

        m_vWndPlugs.add (plug);


        wgTButtonInfo* pButtons;
        int cButtons;
        afnGTBI [i] (&pButtons, &cButtons);
        CBitmap bmp1, bmp2;

        bmp1.Attach (SBMP (aIDBmps [i]));
        bmp2.Attach (SBMP (aIDBmpsD [i]));

        if (_TB_USE_ALPHA)
        {
            ConvertBmp32WithAlphaToBmp32WithoutAlpha (bmp1, GetSysColor (COLOR_3DFACE));
            ConvertBmp32WithAlphaToBmp32WithoutAlpha (bmp2, GetSysColor (COLOR_3DFACE));
        }

        _TBMgr.InsertGroup (pButtons, &bmp1, &bmp2, cButtons);
    }

    return TRUE;
}
Exemple #11
0
BOOL CFdmApp::InitInstance()
{
	g_crashReporter.reset (new vmsAppCrashReporter (
		g_appVersion.getVersion ()->m_tstrProductName,
		L"",
		g_appVersion.getVersion ()->m_tstrFileVersion,
		L"freedownloadmanager.org", L"/dump.php"));

	bool bContinue = true;
	if (g_crashReporter->CheckIfSubmitDumpIsRequestedByCommandLine (bContinue))
	{
		if (!bContinue)
			return FALSE;
	}

	g_crashReporter->InitializeCrashCatcher ();

	AfxEnableControlContainer ();

	{
		_configthreadlocale (_DISABLE_PER_THREAD_LOCALE);
		tstringstream tss;
		tss << _T (".") << GetACP ();
		_tsetlocale(LC_ALL, tss.str ().c_str ());
		_configthreadlocale (_ENABLE_PER_THREAD_LOCALE);
	}

	
	SetRegistryKey (IDS_COMPANY);

	CheckRegistry ();

	fsIECatchMgr::CleanIEPluginKey ();

	
	CString strPath = GetProfileString (_T(""), _T("Path"), _T(""));
	BOOL bNeedLocalRegister = FALSE;
	if (strPath == _T(""))
	{
		CRegKey key;
		if (ERROR_SUCCESS == key.Open (HKEY_CURRENT_USER, _T("Software\\FreeDownloadManager.ORG\\Free Download Manager"), KEY_WRITE))
			vmsSHCopyKey (HKEY_LOCAL_MACHINE, _T("Software\\FreeDownloadManager.ORG\\Free Download Manager"), key);
		strPath = GetProfileString (_T(""), _T("Path"), _T(""));
		bNeedLocalRegister = strPath != "";
	}

	if (GetFileAttributes (strPath + _T("\\fdm.exe")) == DWORD (-1))
	{
		strPath = _T("");
		bNeedLocalRegister = false;
	}

	
	
	if (strPath == _T("") || FALSE == SetCurrentDirectory (strPath))
		_dwAppState |= APPSTATE_PORTABLE_MODE;

	TCHAR tszExeDir [MY_MAX_PATH], tszExeFile [MY_MAX_PATH];
	GetModuleFileName (NULL, tszExeFile, sizeof (tszExeFile));
	fsGetPath (tszExeFile, tszExeDir);

	if (IS_PORTABLE_MODE)
	{
		strPath = tszExeDir;
		SetCurrentDirectory (strPath);
	}

	m_strAppPath = strPath;
	if (m_strAppPath.IsEmpty () == FALSE)
	{
		if (m_strAppPath [m_strAppPath.GetLength ()-1] != '\\' &&
				m_strAppPath [m_strAppPath.GetLength ()-1] != '/')
			m_strAppPath += '\\';
	}

	if (IS_PORTABLE_MODE == false)
	{
		CString strDataFldr = tszExeDir; strDataFldr += _T("Data");
		
		
		
		if (m_strAppPath.CompareNoCase (tszExeDir) &&
			 DWORD (-1) != GetFileAttributes (strDataFldr))
		{
			
			_dwAppState |= APPSTATE_PORTABLE_MODE;
			_dwAppState |= APPSTATE_PORTABLE_MODE_NOREG;
			m_strAppPath = tszExeDir;
		}
	}

	if (IS_PORTABLE_MODE)
	{
		
		vmsAppSettingsStore* pStgs = _App.get_SettingsStore ();
		CString strStgsFile = m_strAppPath + "Data\\settings.dat";
		fsBuildPathToFile (strStgsFile);
		pStgs->LoadSettingsFromFile (strStgsFile);
		_App.ApplySettingsToMutexes ();
	}

	BOOL bNoLng = FALSE;

	if (FALSE == InitLanguage ())
		bNoLng = TRUE;

	if (_tcscmp (m_lpCmdLine, _T("-suis")) == 0 || 
			_tcscmp (m_lpCmdLine, _T("-euis")) == 0 ||
			_tcscmp (m_lpCmdLine, _T("-duis")) == 0)
	{
		IntegrationSettings ();
		return FALSE;
	}

	if (IS_PORTABLE_MODE)
	{
		
		
		
		TCHAR szTmpFile [MY_MAX_PATH];
		CString str = m_strAppPath; str += _T("Data");
		CreateDirectory (str, NULL);
		if (0 == GetTempFileName (str, _T("fdm"), 0, szTmpFile))
			MessageBox (NULL, LS (L_NOWRITEACCESSTODATAFOLDER), vmsFdmAppMgr::getAppName (), MB_ICONWARNING);
		else
			DeleteFile (szTmpFile);
	}

	_SkinMgr.Initialize ();

	_IECatchMgr.ReadSettings ();
	_NOMgr.Initialize ();
	_IECMM.ReadState ();

	
	HRESULT hRes = OleInitialize (NULL);
	
	if (FAILED(hRes))
		return FALSE;
	
	m_bCOMInited = TRUE;

	const tstring currentVersion = vmsFdmAppMgr::getVersion ()->m_fileVersion.ToString ();
	bool currentVersionFirstRun = currentVersion != _App.RecentVersionRun ();
	if (currentVersionFirstRun)
		_App.RecentVersionRun (currentVersion);

	vmsAppGlobalObjects::Create2 (currentVersionFirstRun);

	fsFDMCmdLineParser cmdline;

	cmdline.Parse (fsFDMCmdLineParser::Elevated);

	if (cmdline.isRunAsElevatedTasksProcessor ())
	{
		RunAsElevatedTasksProcessor (cmdline);
		return FALSE;
	}

	if (cmdline.isNeedExit ())
		return FALSE;

	m_bForceSilentSpecified = cmdline.is_ForceSilentSpecified ();

	if (cmdline.isNeedRegisterServer ())
	{
		onNeedRegisterServer ( false );
		return FALSE;
	}
	else if (cmdline.isNeedRegisterServerUserOnly ())
	{
		onNeedRegisterServer ( true );
		return FALSE;
	}
	else if (cmdline.isNeedUnregisterServer ())
	{
		onNeedUnregisterServer ();
		return FALSE;
	}

	if (vmsWinSecurity::os_supports_elevation () && 
		_tcsncmp (m_lpCmdLine, _T("-nelvcheck"), 10) && _tcsicmp (m_lpCmdLine, _T("-autorun")))
	{
		if (vmsWinSecurity::IsProcessElevated ())
		{
			WCHAR wsz [MAX_PATH] = L"";
			GetModuleFileNameW (NULL, wsz, MAX_PATH);
			std::wstring wstr = L"\"";
			wstr += wsz;
			wstr += L"\" -nelvcheck ";
			wstr += CT2WEX<> (m_lpCmdLine);
			_appMutex.CloseMutex ();
			STARTUPINFOW si = {0}; PROCESS_INFORMATION pi = {0};
			si.cb = sizeof (si);
			if (vmsWinSecurity::RunAsDesktopUser (wsz, (LPWSTR)wstr.c_str (), NULL, si, pi))
				return FALSE;
			_appMutex.Create ();
		}
	}

	cmdline.Parse (fsFDMCmdLineParser::Normal);

	if (CheckFdmStartedAlready (m_bForceSilentSpecified == FALSE))
		return FALSE;

	if (!InitATL())
		return FALSE;

	_App.StartCount (_App.StartCount () + 1);

	
	
	if (IS_PORTABLE_MODE && (_dwAppState & APPSTATE_PORTABLE_MODE_NOREG) == 0)
		Install_RegisterServer ();

	
	
	
	
	vmsFilesToDelete::Process ();

	if (bNeedLocalRegister)
		RegisterServer (FALSE);

	

#ifdef _AFXDLL
	Enable3dControls();			
#else
	Enable3dControlsStatic();	
#endif

	CheckLocked ();

	_UpdateMgr.ReadSettings ();
	
	if (_UpdateMgr.IsStartUpdaterNeeded ())
	{
		if (_UpdateMgr.StartUpdater ())	
			return FALSE;	
		else
			::MessageBox (NULL, LS (L_CANTFINDUPDATER), LS (L_ERR), MB_ICONERROR);
	}

	vmsFlvSniffInjector::o ().Enable (_App.FlvMonitoring_Enable () != FALSE);

	LoadHistory ();

	_Snds.ReadSettings ();

	if (!vmsBtSupport::isBtDllValid ())
	{
		MessageBox (NULL, LS (L_INVALID_BT_MODULE), _T ("Free Download Manager"), MB_ICONERROR);
		return FALSE;
	}

	auto ytdllmgr = std::make_shared <vmsYouTubeParserDllMgr> (
		std::make_shared <vmsAppDataFolder> (L"FreeDownloadManager.ORG", L"Free Download Manager"),
		currentVersionFirstRun);
	vmsYouTubeParserDllMgr::reset (ytdllmgr);

	auto avMerger = std::make_shared<vmsAVMergerFFMPEG>();
	auto avAfterMergeAction = std::make_shared<vmsYouTubeAfterMergeAction>();
	auto avYouTubeMergingMgr = std::make_shared <vmsAVMergingMgr>( avMerger, avAfterMergeAction, 1 );	
	_YouTubeDldsMgr.setYouTubeAVMergingMgr( avYouTubeMergingMgr );

	CMainFrame* pFrame = NULL;
	fsnew1 (pFrame, CMainFrame);
	m_pMainWnd = pFrame;

	
	if (FALSE == pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, 
		NULL, NULL))
	{
		return FALSE;
	}

	
	BOOL bHidden = _tcscmp (m_lpCmdLine, _T ("-autorun")) == 0;

	_App.View_ReadWndPlacement (pFrame, _T("MainFrm"), 
		bHidden ? fsAppSettings::RWPA_FORCE_SWHIDE_AND_KEEP_MINIMIZED_MAXIMIZED_STATE : fsAppSettings::RWPA_NONE);

	if (!bHidden)
	{
		if (_App.Prg_StartMinimized ())
		{
			if (IsWindowVisible (pFrame->m_hWnd))
				pFrame->ShowWindow (SW_MINIMIZE);
		}
		else
		{
			pFrame->UpdateWindow();
			if (pFrame->IsWindowVisible ())
				pFrame->SetForegroundWindow ();
		}
	}

	m_bStarting = FALSE;

	
	hRes = _Module.RegisterClassObjects (CLSCTX_LOCAL_SERVER, 
				REGCLS_MULTIPLEUSE);
	if (FAILED (hRes))
	{
		LPVOID lpMsgBuf;
		FormatMessage( 
				FORMAT_MESSAGE_ALLOCATE_BUFFER | 
				FORMAT_MESSAGE_FROM_SYSTEM | 
				FORMAT_MESSAGE_IGNORE_INSERTS,
				NULL,
				hRes,
				MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 
				(LPTSTR) &lpMsgBuf,
				0,
				NULL 
				);
			
			
			
			MessageBox( NULL, (LPCTSTR)lpMsgBuf, nullptr, MB_OK | MB_ICONINFORMATION );
			
			LocalFree( lpMsgBuf );
	}
	m_bATLInited2 = SUCCEEDED (hRes);

	return TRUE;
}