void vmsDownloadMgrEx::Do_OpenFolder() { if (m_pMgr && m_pMgr->IsFileInit () == FALSE) { ShellExecute (NULL, _T("explore"), get_OutputFilePathName (), NULL, NULL, SW_SHOW); } else { CString strFileName = get_OutputFilePathName (); if (m_spBtMgr && m_spBtMgr->get_FileCount () > 1) strFileName += m_spBtMgr->get_RootFolderName (); if (GetFileAttributes (strFileName) == DWORD (-1)) { TCHAR szPath [MY_MAX_PATH]; fsGetPath (strFileName, szPath); ShellExecute (NULL, _T("explore"), szPath, NULL, NULL, SW_SHOW); } else { CString strCmd; strCmd.Format (_T("/select,\"%s\""), strFileName); ShellExecute (NULL, _T("open"), _T("explorer.exe"), strCmd, NULL, SW_SHOW); } } }
BOOL fsBuildPathToFile (LPCSTR pszFileName) { CHAR szPath [MAX_PATH]; fsGetPath (pszFileName, szPath); int len = lstrlen (szPath); int start = 0; if (szPath [1] == ':') start = 3; for (int i = start; i < len; i++) { if (szPath [i] == '\\' || szPath [i] == '/') { CHAR szPath2 [MAX_PATH]; CopyMemory (szPath2, szPath, i); szPath2 [i] = 0; if (FALSE == CreateDirectory (szPath2, NULL)) { if (GetLastError () != ERROR_ALREADY_EXISTS) return FALSE; } } } return TRUE; }
void CBtDld_General::OnChoosefolder() { CString str = ""; GetDlgItemText (IDC_SAVEIN, str); if ((GetFileAttributes (str) & FILE_ATTRIBUTE_DIRECTORY) == 0) { char sz [MY_MAX_PATH]; fsGetPath (str, sz); str = sz; } if (str.GetLength () > 3 && (str [str.GetLength () - 1] == '\\' || str [str.GetLength () - 1] == '/')) { str.GetBuffer (0) [str.GetLength () - 1] = 0; str.ReleaseBuffer (); } CFolderBrowser *fb = CFolderBrowser::Create (LS (L_CHOOSEOUTFOLDER), str, NULL, this); if (fb == NULL) return; for (size_t i = 0; i < m_pvDlds->size (); i++) m_pvDlds->at (i)->pMgr->MoveToFolder (fb->GetPath ()); ReadSavedIn (); }
BOOL fsBuildPathToFile (LPCSTR pszFileName) { CHAR szPath [MAX_PATH]; fsGetPath (pszFileName, szPath); int len = strlen (szPath); int start = 0; if (szPath [0] == '\\' && szPath [1] == '\\') { LPCSTR psz = strchr (szPath + 2, '\\'); if (psz) psz = strchr (psz+1, '\\'); if (psz) psz++; if (psz == NULL) { SetLastError (ERROR_PATH_NOT_FOUND); return FALSE; } start = psz - szPath; } else { if (szPath [1] == ':') start = 3; } for (int i = start; i < len; i++) { if (szPath [i] == '\\' || szPath [i] == '/') { CHAR szPath2 [MAX_PATH]; CopyMemory (szPath2, szPath, i); szPath2 [i] = 0; if (FALSE == CreateDirectory (szPath2, NULL)) { if (GetLastError () != ERROR_ALREADY_EXISTS) return FALSE; } } } return TRUE; }
void CDownloads_History::OnOpenfolder() { fsDLHistoryRecord* rec = get_SelectedRecord (); if (GetFileAttributes (rec->strSavedTo) == DWORD (-1)) { char szPath [MY_MAX_PATH]; fsGetPath (rec->strSavedTo, szPath); ShellExecute (m_hWnd, "explore", szPath, NULL, NULL, SW_SHOW); } else { CString strCmd; strCmd.Format ("/select,\"%s\"", rec->strSavedTo); ShellExecute (m_hWnd, "open", "explorer.exe", strCmd, NULL, SW_SHOW); } }
void fsGetFileName (LPCSTR pszFilePath, LPSTR pszFileName) { CHAR szPath [MAX_PATH]; fsGetPath (pszFilePath, szPath); strcpy (pszFileName, pszFilePath + strlen (szPath)); }
void fsOpNetIntegrationMgr::Initialize() { CRegKey key; CString strOpKey = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Opera.exe"; CString strNetKey1 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Netscp.exe"; CString strNetKey2 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Netscp6.exe"; CString strNetKey3 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Netscape.exe"; CString strNetKey4 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\navigator.exe"; CString strFfKey = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Firefox.exe"; CString strMozSKey1 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\SeaMonkey.exe"; CString strMozSKey2 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\mozilla.exe"; if (ERROR_SUCCESS == key.Open (HKEY_CURRENT_USER, "Software\\Opera Software", KEY_READ)) { char szPath [MY_MAX_PATH] = ""; DWORD dw = sizeof (szPath); if (ERROR_SUCCESS == key.QueryValue (szPath, "Plugin Path", &dw)) { if (*szPath) { m_strOpPath = szPath; if (m_strOpPath [m_strOpPath.GetLength () - 1] != '\\' || m_strOpPath [m_strOpPath.GetLength () - 1] != '/') m_strOpPath += '\\'; } } } if (m_strOpPath == "" && ERROR_SUCCESS == key.Open (HKEY_CLASSES_ROOT, "Applications\\Opera.exe\\shell\\open\\command", KEY_READ)) { char sz [MY_MAX_PATH] = ""; DWORD dw = sizeof (sz); key.QueryValue (sz, NULL, &dw); vmsCommandLine cl; cl.fromString (sz, true); if (cl.getExe () != NULL && *cl.getExe () != 0) { *sz = 0; fsGetPath (cl.getExe (), sz); if (*sz) { m_strOpPath = sz; if (m_strOpPath [m_strOpPath.GetLength () - 1] != '\\' || m_strOpPath [m_strOpPath.GetLength () - 1] != '/') m_strOpPath += '\\'; if (GetFileAttributes (m_strOpPath + "program\\plugins") != DWORD (-1)) m_strOpPath += "program\\plugins\\"; else m_strOpPath += "Plugins\\"; } } } if (m_strOpPath == "" && ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strOpKey, KEY_READ)) { char szPath [MY_MAX_PATH] = ""; DWORD dw = sizeof (szPath); key.QueryValue (szPath, "Path", &dw); if (*szPath) { m_strOpPath = szPath; if (m_strOpPath [m_strOpPath.GetLength () - 1] != '\\' || m_strOpPath [m_strOpPath.GetLength () - 1] != '/') m_strOpPath += '\\'; if (GetFileAttributes (m_strOpPath + "program\\plugins") != DWORD (-1)) m_strOpPath += "program\\plugins\\"; else m_strOpPath += "Plugins\\"; } key.Close (); } if (m_strOpPath == "") { m_strOpPath = _App.Monitor_OperaPDInstalledTo (); } if (ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strNetKey1, KEY_READ) || ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strNetKey2, KEY_READ) || ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strNetKey3, KEY_READ) || ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strNetKey4, KEY_READ)) { char szPath [MY_MAX_PATH] = ""; DWORD dw = sizeof (szPath); key.QueryValue (szPath, "Path", &dw); if (*szPath) { m_strNetPath = szPath; if (m_strNetPath [m_strNetPath.GetLength () - 1] != '\\' || m_strNetPath [m_strNetPath.GetLength () - 1] != '/') m_strNetPath += '\\'; m_strNetPath += "Plugins\\"; } key.Close (); if (m_strNetPath == m_strOpPath) m_strNetPath = _App.Monitor_NetscapePDInstalledTo (); } else { m_strNetPath = _App.Monitor_NetscapePDInstalledTo (); } if (ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strFfKey, KEY_READ)) { char szPath [MY_MAX_PATH] = ""; DWORD dw = sizeof (szPath); key.QueryValue (szPath, "Path", &dw); if (*szPath) { m_strFfPath = szPath; if (m_strFfPath [m_strFfPath.GetLength () - 1] != '\\' || m_strFfPath [m_strFfPath.GetLength () - 1] != '/') m_strFfPath += '\\'; m_strFfPath += "Plugins\\"; } key.Close (); } else { m_strFfPath = _App.Monitor_FirefoxPDInstalledTo (); } if (ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strMozSKey1, KEY_READ) || ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strMozSKey2, KEY_READ)) { char szPath [MY_MAX_PATH] = ""; DWORD dw = sizeof (szPath); key.QueryValue (szPath, "Path", &dw); if (*szPath) { m_strMozSPath = szPath; if (m_strMozSPath [m_strMozSPath.GetLength () - 1] != '\\' || m_strMozSPath [m_strMozSPath.GetLength () - 1] != '/') m_strMozSPath += '\\'; m_strMozSPath += "Plugins\\"; } key.Close (); } else { m_strMozSPath = _App.Monitor_MozillaSuitePDInstalledTo (); } if (ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, "Software\\Clients\\StartMenuInternet\\Safari.exe\\shell\\open\\command", KEY_READ)) { char szCmd [MY_MAX_PATH] = ""; DWORD dw = sizeof (szCmd); key.QueryValue (szCmd, NULL, &dw); if (*szCmd) { LPSTR psz = szCmd; if (*psz == '"') { LPSTR psz2 = strchr (psz+1, '"'); if (psz2) *psz2 = 0; psz++; } else { LPSTR psz2 = strchr (psz, ' '); if (psz2) *psz2 = 0; } LPSTR psz3 = strrchr (psz, '\\'); if (psz3) psz3 [1] = 0; strcat (psz, "Plugins\\"); m_strSafariPath = psz; } } else { m_strSafariPath = _App.Monitor_SafariPDInstalledTo (); } if (ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, "Software\\Clients\\StartMenuInternet\\chrome.exe\\shell\\open\\command", KEY_READ)) { char szCmd [MY_MAX_PATH] = ""; DWORD dw = sizeof (szCmd); key.QueryValue (szCmd, NULL, &dw); if (*szCmd) { LPSTR psz = szCmd; if (*psz == '"') { LPSTR psz2 = strchr (psz+1, '"'); if (psz2) *psz2 = 0; psz++; } else { LPSTR psz2 = strchr (psz, ' '); if (psz2) *psz2 = 0; } LPSTR psz3 = strrchr (psz, '\\'); if (psz3) psz3 [1] = 0; strcat (psz, "Plugins\\"); m_strChromePath = psz; } } else { LPITEMIDLIST pidl = NULL; if (SUCCEEDED (SHGetSpecialFolderLocation (NULL, CSIDL_LOCAL_APPDATA, &pidl))) { TCHAR tszPath [MY_MAX_PATH] = _T (""); SHGetPathFromIDList (pidl, tszPath); if (tszPath [_tcslen (tszPath)-1] != '\\') _tcscat (tszPath, _T ("\\")); _tcscat (tszPath, _T ("Google\\Chrome\\Application")); if (GetFileAttributes (tszPath) != DWORD (-1)) { _tcscat (tszPath, _T ("\\Plugins\\")); m_strChromePath = tszPath; } IMallocPtr spMalloc; SHGetMalloc (&spMalloc); spMalloc->Free (pidl); } if (m_strChromePath.IsEmpty ()) m_strChromePath = _App.Monitor_ChromePDInstalledTo (); } }
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; }