BOOL CHostBaseDownloadDlg::OnInitDialog() { CDialog::OnInitDialog(); CComboBox* baudrateCombo = (CComboBox*)GetDlgItem(IDC_BAUDRATE_IDX); CComboBox* bufferCombo = (CComboBox*)GetDlgItem(IDC_BUFFER_IDX); g_setting.InitBaudrateCombo(baudrateCombo); baudrateCombo->AddString("SPI"); CRegistry reg; reg.SetRootKey(HKEY_CURRENT_USER); if(reg.SetKey(VIEWER_REG_PATH, TRUE)) { m_nBaudrateIdx = reg.ReadInt("hb_baudrate", g_setting.boostBaudIndex); m_strPath = reg.ReadString("hb_firmware", ""); m_nBufferIdx = reg.ReadInt("hb_buffer", 0); } else { m_nBaudrateIdx = BAUDRATE_DEFAULT; } if(m_strPath.IsEmpty()) { m_strPath = theApp.GetCurrrentDir(); m_strPath += "\\host.bin"; } baudrateCombo->SetCurSel(m_nBaudrateIdx); GetDlgItem(IDC_IMG_PATH)->SetWindowText(m_strPath); bufferCombo->SetCurSel(m_nBufferIdx); return TRUE; // return TRUE unless you set the focus to a control }
void CSettings::EnableAutostartup(bool enable) { CRegistry Reg; Reg.SetRootKey( HKEY_CURRENT_USER ); bool canCreateRegistryKey = enable; if ( Reg.SetKey( "Software\\Zenden.ws\\Image Uploader", canCreateRegistryKey ) ) { if ( enable ) { Reg.WriteBool( "AutoStartup", enable ); } else { Reg.DeleteValue("AutoStartup"); } } if ( enable ) { HKEY hKey; CString StartupCommand = _T("\"") + CmdLine.ModuleName() + _T("\" /tray"); LONG lRet, lRetOpen; lRet = RegOpenKeyEx( HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_WRITE, &hKey ); if (!lRet) { lRetOpen = RegSetValueEx( hKey, _T("ImageUploader"), NULL, REG_SZ, (BYTE*)(LPCTSTR)StartupCommand, (StartupCommand.GetLength() + 1) * sizeof(TCHAR)); } RegCloseKey( hKey ); } else { // deleting from Startup (autorun) HKEY hKey; LONG lRet; lRet = RegOpenKeyEx( HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_WRITE, &hKey ); RegDeleteValue( hKey, _T("ImageUploader") ); } }
void CGpsdoDownload::LoadSetting() { CRegistry reg; reg.SetRootKey(HKEY_CURRENT_USER); if(reg.SetKey("Software\\GNSSViewer\\GPS", true)) { m_strMasterPath = reg.ReadString("gpsdo_fw_dn_master_path", ""); m_strSlavePath = reg.ReadString("gpsdo_fw_dn_slave_path", ""); } }
void CGpsdoDownload::SaveSetting() { //m_nBaudrateIdx = ((CComboBox*)GetDlgItem(IDC_BAUDRATE_IDX))->GetCurSel(); CRegistry reg; reg.SetRootKey(HKEY_CURRENT_USER); if(reg.SetKey("Software\\GNSSViewer\\GPS", false)) { reg.WriteString("gpsdo_fw_dn_master_path", m_strMasterPath); reg.WriteString("gpsdo_fw_dn_slave_path", m_strSlavePath); //reg.WriteInt("fw_baudrate", m_nBaudrateIdx); } }
//======================================================================================= // FUNCTION : 동부DRCM의 정보를 레지스트리에서 가져옴 // RETURN : //======================================================================================= BOOL CDongbuAPIClientDlg::GetDRCMInfo(CString &szRoot, CString &szExe, CString &szWinName ) { CRegistry registry; registry.SetRootKey(HKEY_CURRENT_USER); registry.SetKey("Software\\Dongbu Securities\\DongbuDRCM\\PATH", FALSE); szRoot = registry.ReadString("Root", ""); szExe = registry.ReadString("Exe", ""); szWinName = registry.ReadString("WinName", ""); if ( szRoot.IsEmpty() || szExe.IsEmpty() || szWinName.IsEmpty()) return FALSE ; else return TRUE ; }
void CHostBaseDownloadDlg::GetValue() { m_nBaudrateIdx = ((CComboBox*)GetDlgItem(IDC_BAUDRATE_IDX))->GetCurSel(); GetDlgItem(IDC_IMG_PATH)->GetWindowText(m_strPath); m_nBufferIdx = ((CComboBox*)GetDlgItem(IDC_BUFFER_IDX))->GetCurSel(); CRegistry reg; reg.SetRootKey(HKEY_CURRENT_USER); if(reg.SetKey(VIEWER_REG_PATH, false)) { reg.WriteInt("hb_baudrate", m_nBaudrateIdx); reg.WriteString("hb_firmware", m_strPath); reg.WriteInt("hb_buffer", m_nBufferIdx); } }
BOOL CHostBaseDownloadDlg::OnInitDialog() { CDialog::OnInitDialog(); CComboBox* baudrateCombo = (CComboBox*)GetDlgItem(IDC_BAUDRATE_IDX); CComboBox* bufferCombo = (CComboBox*)GetDlgItem(IDC_BUFFER_IDX); if(_V8_SUPPORT) { baudrateCombo->ResetContent(); for(int i=0; i<9; ++i) { CString strIdx; strIdx.Format("%d", CSerial::BaudrateTable[i]); baudrateCombo->AddString(strIdx); } } baudrateCombo->AddString("SPI"); CRegistry reg; reg.SetRootKey(HKEY_CURRENT_USER); if(reg.SetKey("Software\\GNSSViewer\\GPS", true)) { m_nBaudrateIdx = reg.ReadInt("hb_baudrate", g_setting.boostBaudIndex); m_strPath = reg.ReadString("hb_firmware", ""); m_nBufferIdx = reg.ReadInt("hb_buffer", 0); } else { m_nBaudrateIdx = BAUDRATE_DEFAULT; } if(m_strPath.IsEmpty()) { m_strPath = theApp.GetCurrrentDir(); m_strPath += "\\host.bin"; } baudrateCombo->SetCurSel(m_nBaudrateIdx); GetDlgItem(IDC_IMG_PATH)->SetWindowText(m_strPath); bufferCombo->SetCurSel(m_nBufferIdx); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX 屬性頁應傳回 FALSE }
void CParallelDownloadDlg::OnOK() { //m_nBaudrateIdx = ((CComboBox*)GetDlgItem(IDC_BAUDRATE_IDX))->GetCurSel(); m_nFlashType = ((CComboBox*)GetDlgItem(IDC_FLASH_TYPE))->GetCurSel(); GetDlgItem(IDC_IMG_PATH)->GetWindowText(m_strPath); // m_isInternal = ((CButton*)GetDlgItem(IDC_IN_LOADER))->GetCheck(); // m_nBufferIdx = ((CComboBox*)GetDlgItem(IDC_BUFFER_IDX))->GetCurSel(); CRegistry reg; reg.SetRootKey(HKEY_CURRENT_USER); if(reg.SetKey(VIEWER_REG_PATH, false)) { //reg.WriteInt("pl_baudrate", m_nBaudrateIdx); reg.WriteInt("pl_flashtype", m_nFlashType); reg.WriteString("pl_firmware", m_strPath); //reg.WriteInt("pl_internal", m_isInternal); //reg.WriteInt("pl_buffer", m_nBufferIdx); } CDialog::OnOK(); }
// CParallelDownloadDlg BOOL CParallelDownloadDlg::OnInitDialog() { CDialog::OnInitDialog(); //CComboBox* baudrateCombo = (CComboBox*)GetDlgItem(IDC_BAUDRATE_IDX); CComboBox* flashTypeCombo = (CComboBox*)GetDlgItem(IDC_FLASH_TYPE); CComboBox* bufferCombo = (CComboBox*)GetDlgItem(IDC_BUFFER_IDX); CRegistry reg; reg.SetRootKey(HKEY_CURRENT_USER); if(reg.SetKey(VIEWER_REG_PATH, true)) { //m_nBaudrateIdx = reg.ReadInt("pl_baudrate", setting->boostBaudIndex); //m_nBaudrateIdx = setting->boostBaudIndex; m_nFlashType = reg.ReadInt("pl_flashtype", 0); m_strPath = reg.ReadString("pl_firmware", ""); //m_nBufferIdx = reg.ReadInt("pl_buffer", 0); } else { m_nBaudrateIdx = g_setting.boostBaudIndex; m_nFlashType = 0; } if(m_strPath.IsEmpty()) { m_strPath = theApp.GetCurrrentDir(); m_strPath += "\\prom.bin"; } //baudrateCombo->SetCurSel(m_nBaudrateIdx); flashTypeCombo->SetCurSel(m_nFlashType); GetDlgItem(IDC_IMG_PATH)->SetWindowText(m_strPath); //((CButton*)GetDlgItem(IDC_IN_LOADER))->SetCheck(m_isInternal); //bufferCombo->SetCurSel(m_nBufferIdx); return TRUE; // return TRUE unless you set the focus to a control }
void RegisterShellExtension(bool Register) { CString moduleName = Settings.getShellExtensionFileName(); if ( !FileExists( moduleName ) ) { return; } CRegistry Reg; Reg.SetRootKey( HKEY_LOCAL_MACHINE ); bool canCreateRegistryKey = Register; if ( Reg.SetKey( "Software\\Zenden.ws\\Image Uploader", canCreateRegistryKey ) ) { Reg.WriteBool( "ExplorerContextMenu", Register ); } SHELLEXECUTEINFO TempInfo = {0}; CString s = WinUtils::GetAppFolder(); TempInfo.cbSize = sizeof(SHELLEXECUTEINFOA); TempInfo.fMask = SEE_MASK_NOCLOSEPROCESS; TempInfo.hwnd = NULL; BOOL b = FALSE; IsElevated( &b ); if ( IsVista() && !b ) { TempInfo.lpVerb = _T("runas"); } else { TempInfo.lpVerb = _T("open"); } TempInfo.lpFile = _T("regsvr32"); TempInfo.lpParameters = CString((Register ? _T("") : _T("/u "))) + _T("/s \"") + moduleName + _T("\""); TempInfo.lpDirectory = s; TempInfo.nShow = SW_NORMAL; //MessageBox(0,TempInfo.lpParameters,0,0); ::ShellExecuteEx(&TempInfo); WaitForSingleObject( TempInfo.hProcess, INFINITE ); CloseHandle( TempInfo.hProcess ); }
bool CSettings::SaveSettings() { SimpleXml xml; mgr_.saveToXmlNode(xml.getRoot("ImageUploader").GetChild("Settings")); #if !defined(IU_SERVERLISTTOOL) && !defined (IU_CLI) && !defined(IU_SHELLEXT) SaveConvertProfiles(xml.getRoot("ImageUploader").GetChild("Settings").GetChild("Image").GetChild("Profiles")); SaveServerProfiles( xml.getRoot("ImageUploader").GetChild("Settings").GetChild("Uploading").GetChild("ServerProfiles") ); #endif SaveAccounts(xml.getRoot("ImageUploader").GetChild("Settings").GetChild("ServersParams")); //std::cerr << "Saving setting to "<< IuCoreUtils::WstringToUtf8((LPCTSTR)fileName_); xml.SaveToFile(fileName_); #if !defined(IU_SERVERLISTTOOL) && !defined(IU_CLI) CRegistry Reg; Reg.SetRootKey(HKEY_CURRENT_USER); // if(ExplorerContextMenu) { bool canCreateRegistryKey = ( ExplorerContextMenu ); if ( Reg.SetKey("Software\\Zenden.ws\\Image Uploader", canCreateRegistryKey ) ) { if ( ExplorerContextMenu ) { Reg.WriteBool( "ExplorerCascadedMenu", ExplorerCascadedMenu ); Reg.WriteBool("ExplorerContextMenu", ExplorerContextMenu); Reg.WriteBool( "ExplorerVideoContextMenu", ExplorerVideoContextMenu ); Reg.WriteString( "Language", Language ); } else { Reg.DeleteValue("ExplorerCascadedMenu"); Reg.DeleteValue("ExplorerContextMenu"); Reg.DeleteValue("ExplorerVideoContextMenu"); Reg.DeleteValue("Language"); } } } /*else { //Reg.DeleteKey("Software\\Zenden.ws\\Image Uploader"); }*/ EnableAutostartup(AutoStartup); if (SendToContextMenu_changed || ExplorerContextMenu_changed) { AutoStartup_changed = false; BOOL b; if ( IsVista() && IsElevated(&b) != S_OK ) { // Start new elevated process ApplyRegistrySettings(); } else { // Process has already admin rights ApplyRegSettingsRightNow(); } } ExplorerContextMenu_changed = false; SendToContextMenu_changed = false; if (ShowTrayIcon_changed) { ShowTrayIcon_changed = false; if (ShowTrayIcon) { if (!IsRunningFloatingWnd()) { CmdLine.AddParam(_T("/tray")); floatWnd.CreateTrayIcon(); } } else { HWND TrayWnd = FindWindow(0, _T("ImageUploader_TrayWnd")); if (TrayWnd) { ::SendMessage( TrayWnd, WM_CLOSETRAYWND, 0, 0 ); } } } else if (ShowTrayIcon) { HWND TrayWnd = FindWindow(0, _T("ImageUploader_TrayWnd")); if (TrayWnd) SendMessage(TrayWnd, WM_RELOADSETTINGS, (floatWnd.m_hWnd) ? 1 : 0, (Settings.Hotkeys_changed) ? 0 : 1); } Settings.Hotkeys_changed = false; #endif return true; }
bool CSettings::LoadSettings(std::string szDir, std::string fileName, bool LoadFromRegistry ) { fileName_ = !szDir.empty() ? szDir + ( (!fileName .empty())? fileName : "Settings.xml") : SettingsFolder + ( !fileName.empty() ? fileName : "Settings.xml"); //std::cout<< fileName_; //MessageBoxA(0,fileName_.c_str(),0,0); if ( !IuCoreUtils::FileExists( fileName_) ) { return true; } SimpleXml xml; xml.LoadFromFile( fileName_ ); mgr_.loadFromXmlNode( xml.getRoot("ImageUploader").GetChild("Settings") ); SimpleXmlNode settingsNode = xml.getRoot( "ImageUploader" ).GetChild( "Settings" ); #if !defined(IU_CLI) && !defined( IU_SHELLEXT) && !defined(IU_SERVERLISTTOOL) std::string temp; if ( !settingsNode["Image"]["Format"].IsNull() ) { // for compatibility with old version configuration file LoadConvertProfile( "Old profile", settingsNode ); } if ( CmdLine.IsOption(_T("afterinstall") )) { if ( CmdLine.IsOption(_T("usenewicon") )) { UseNewIcon = true; } else { UseNewIcon = false; } SaveSettings(); } // Migrating from 1.3.0 to 1.3.1 (added ImageEditor has been addded) if (settingsNode["ImageEditor"].IsNull() ) { if ( Settings.TrayIconSettings.TrayScreenshotAction == TRAY_SCREENSHOT_UPLOAD ) { TrayIconSettings.TrayScreenshotAction = TRAY_SCREENSHOT_OPENINEDITOR; } } LoadConvertProfiles( settingsNode.GetChild("Image").GetChild("Profiles") ); LoadServerProfiles( settingsNode.GetChild("Uploading").GetChild("ServerProfiles") ); #endif LoadAccounts( xml.getRoot( "ImageUploader" ).GetChild( "Settings" ).GetChild( "ServersParams" ) ); #if !defined(IU_CLI) && !defined( IU_SHELLEXT) && !defined(IU_SERVERLISTTOOL) // Fixing profies if ( !imageServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(imageServer.serverName())].find(WCstringToUtf8(imageServer.profileName())) == ServersSettings[WCstringToUtf8(imageServer.serverName())].end() ) { imageServer.setProfileName(""); } if ( !fileServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(fileServer.serverName())].find(WCstringToUtf8(fileServer.profileName())) == ServersSettings[WCstringToUtf8(fileServer.serverName())].end() ) { fileServer.setProfileName(""); } if ( !contextMenuServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(contextMenuServer.serverName())].find(WCstringToUtf8(contextMenuServer.profileName())) == ServersSettings[WCstringToUtf8(contextMenuServer.serverName())].end() ) { contextMenuServer.setProfileName(""); } if ( !quickScreenshotServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(quickScreenshotServer.serverName())].find(WCstringToUtf8(quickScreenshotServer.profileName())) == ServersSettings[WCstringToUtf8(quickScreenshotServer.serverName())].end() ) { quickScreenshotServer.setProfileName(""); } if ( !urlShorteningServer.profileName().IsEmpty() && ServersSettings[WCstringToUtf8(urlShorteningServer.serverName())].find(WCstringToUtf8(urlShorteningServer.profileName())) == ServersSettings[WCstringToUtf8(urlShorteningServer.serverName())].end() ) { urlShorteningServer.setProfileName(""); } if ( UploadBufferSize == 65536) { UploadBufferSize = 1024 * 1024; } #endif #if !defined(IU_CLI) && !defined(IU_SERVERLISTTOOL) // Loading some settings from registry if ( LoadFromRegistry ) { CRegistry Reg; Reg.SetRootKey( HKEY_LOCAL_MACHINE ); if ( Reg.SetKey("Software\\Zenden.ws\\Image Uploader", false ) ) { ExplorerContextMenu = Reg.ReadBool("ExplorerContextMenu", false); } else { ExplorerContextMenu = false; } } CRegistry Reg; Reg.SetRootKey( HKEY_CURRENT_USER ); if ( Reg.SetKey("Software\\Zenden.ws\\Image Uploader", false ) ) { ExplorerCascadedMenu = Reg.ReadBool( "ExplorerCascadedMenu", true); ExplorerVideoContextMenu = Reg.ReadBool( "ExplorerVideoContextMenu", true); } CRegistry Reg2; Reg2.SetRootKey(HKEY_CURRENT_USER); if ( Reg2.SetKey("Software\\Zenden.ws\\Image Uploader", false ) ) { AutoStartup = Reg2.ReadBool("AutoStartup", false); } if ( VideoSettings.Engine != VideoEngineDirectshow && VideoSettings.Engine != VideoEngineFFmpeg && VideoSettings.Engine != VideoEngineAuto ){ VideoSettings.Engine = VideoEngineAuto; } if ( !IsFFmpegAvailable() ){ VideoSettings.Engine = VideoEngineDirectshow; } #endif return true; }
/* Determine where data folder is situated and store it's path into DataFolder member */ void CSettings::FindDataFolder() { AppParams* params = AppParams::instance(); if (IsDirectory(WinUtils::GetAppFolder() + _T("Data"))) { DataFolder = WinUtils::GetAppFolder() + _T("Data\\"); SettingsFolder = IuCoreUtils::WstringToUtf8(static_cast<LPCTSTR>(DataFolder)); params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "\\", "/")); params->setSettingsDirectory(IuStringUtils::Replace(SettingsFolder, "\\", "/")); IsPortable = true; return; } SettingsFolder = IuCoreUtils::WstringToUtf8(static_cast<LPCTSTR>(GetApplicationDataPath() + _T("Image Uploader\\"))); params->setSettingsDirectory(IuStringUtils::Replace(SettingsFolder, "\\", "/")); #if !defined(IU_SERVERLISTTOOL) && !defined (IU_CLI) && !defined(IU_SHELLEXT) { CRegistry Reg; CString lang; Reg.SetRootKey(HKEY_CURRENT_USER); if (Reg.SetKey("Software\\Zenden.ws\\Image Uploader", false)) { CString dir = Reg.ReadString("DataPath"); if (!dir.IsEmpty() && IsDirectory(dir)) { DataFolder = dir; params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "\\", "/")); return; } } } { CRegistry Reg; Reg.SetRootKey(HKEY_LOCAL_MACHINE); if (Reg.SetKey("Software\\Zenden.ws\\Image Uploader", false)) { CString dir = Reg.ReadString("DataPath"); if (!dir.IsEmpty() && IsDirectory(dir)) { DataFolder = dir; params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "\\", "/")); return; } } } if (FileExists(GetCommonApplicationDataPath() + SETTINGS_FILE_NAME)) { DataFolder = GetCommonApplicationDataPath() + _T("Image Uploader\\"); params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "\\", "/")); } else #endif { DataFolder = GetApplicationDataPath() + _T("Image Uploader\\"); params->setDataDirectory(IuStringUtils::Replace(IuCoreUtils::WstringToUtf8((LPCTSTR)DataFolder), "\\", "/")); } }