private void button4_Click(object sender, EventArgs e) { RegistryKey bk = Registry.ClassesRoot; RegistryKey sk = bk.CreateSubKey("*\\shell\\RightClickDeposit"); ModifyRegistry reg = new ModifyRegistry(); reg.BaseRegistryKey = bk; reg.SubKey = "*\\shell\\RightClickDeposit"; reg.Write("MUIVerb", "Deposit to"); string commandList = ""; foreach(KeyValuePair<int,Profile> p in profiles) { if (p.Value.IsDefault()) { string commandName = "RightClickDeposit.deposit." + p.Value.GetId(); commandList += commandName + "; "; RegistryKey cbk = Registry.LocalMachine; RegistryKey ck = cbk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\" + commandName); ModifyRegistry regcmd = new ModifyRegistry(); regcmd.BaseRegistryKey = cbk; regcmd.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\" + commandName; regcmd.Write("MUIVerb", p.Value.GetName()); MessageBox.Show(regcmd.Read("MUIVerb")); RegistryKey cck = cbk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\" + commandName + "\\command"); regcmd.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\" + commandName + "\\command"; regcmd.Write("", "C:\\RightClickDeposit.exe " + p.Value.GetId() + " create \"%1\""); } } RegistryKey ubk = Registry.LocalMachine; RegistryKey uk = ubk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.update"); ModifyRegistry regu = new ModifyRegistry(); regu.BaseRegistryKey = ubk; regu.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.update"; regu.Write("MUIVerb", "Update or delete previous deposit"); RegistryKey cuk = ubk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.update\\command"); regu.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.update\\command"; regu.Write("", "C:\\RightClickDeposit.exe 0 update \"%1\""); commandList += "RightClickDeposit.update"; reg.Write("SubCommands", commandList); }
public bool IsNewFile(Stream inputStream) { using (MD5 md5Hash = MD5.Create()) { string newHash = GetMd5Hash(md5Hash, inputStream); ModifyRegistry registry = new ModifyRegistry(); registry.ShowError = false; string oldHash = registry.Read("Hash"); if (String.IsNullOrEmpty(oldHash)) { registry.Write("Hash", "0"); } bool result = !IsSame(newHash, oldHash); if (result) // if new file need to parse { registry.Write("Hash", newHash); } return result; } }
private void SetupCommandBarButton() { if (runServerViolationsCommandBarButton != null) runServerViolationsCommandBarButton.Delete(true); if (runLocalViolationsCommandBarButton != null) runLocalViolationsCommandBarButton.Delete(true); if (runAllLocalViolationsCommandBarButton != null) runAllLocalViolationsCommandBarButton.Delete(true); if (runServerCoverageCommandBarButton != null) runServerCoverageCommandBarButton.Delete(true); if (runSourceDiffCommandBarButton != null) runSourceDiffCommandBarButton.Delete(true); if (runResetCommandBarButton != null) runResetCommandBarButton.Delete(true); if ((temporaryToolbar != null)) { ModifyRegistry createRegistry = new ModifyRegistry(PLUGINKEY); createRegistry.Write(ROWINDEXKEY, temporaryToolbar.RowIndex); createRegistry.Write(POSITIONKEY, temporaryToolbar.Position); createRegistry.Write(WIDTHKEY, temporaryToolbar.Width); createRegistry.Write(HEIGHTKEY, temporaryToolbar.Height); createRegistry.Write(VISIBLEKEY, temporaryToolbar.Visible); temporaryToolbar.Delete(); } }
/// <summary> /// Builds the toolbar buttons and the context menu items. /// </summary> public void AddTemporaryUI() { const string VS_STANDARD_COMMANDBAR_NAME = "Standard"; const string VS_CODE_WINDOW_COMMANDBAR_NAME = "Code Window"; const string MY_TEMPORARY_TOOLBAR_CAPTION = "Sonar Toolbar"; CommandBar standardCommandBar = null; CommandBar codeCommandBar = null; CommandBars commandBars = null; try { // Retrieve the collection of commandbars // Note: // - In VS.NET 2002/2003 (which uses the Office.dll reference) // DTE.CommandBars returns directly a CommandBars type, so a cast // to CommandBars is redundant // - In VS 2005 or higher (which uses the new Microsoft.VisualStudio.CommandBars.dll reference) // DTE.CommandBars returns an Object type, so we do need a cast to CommandBars commandBars = (CommandBars)applicationObject.CommandBars; standardCommandBar = commandBars[VS_STANDARD_COMMANDBAR_NAME]; codeCommandBar = commandBars[VS_CODE_WINDOW_COMMANDBAR_NAME]; ModifyRegistry createRegistry = new ModifyRegistry(PLUGINKEY); temporaryToolbar = commandBars.Add(MY_TEMPORARY_TOOLBAR_CAPTION, MsoBarPosition.msoBarTop, System.Type.Missing, true); try { int row_index = (int)createRegistry.Read(ROWINDEXKEY); temporaryToolbar.RowIndex = row_index; } catch (System.Exception) { } FormatBarAndButtons(codeCommandBar); try { bool visible = Convert.ToBoolean(createRegistry.Read(VISIBLEKEY)); temporaryToolbar.Visible = visible; } catch (System.Exception) { temporaryToolbar.Visible = true; } } catch(System.Exception e) { System.Windows.Forms.MessageBox.Show("Cannot Add ToolBar: " + e.StackTrace); } }
/// <summary> /// Tries to find game pathes etc. in the registry or other places /// and stores them in a Dictionary. /// Must be called before pathes are accessed through GetPath. /// </summary> public void GatherPathes() { // ======================================= // Misc // ======================================= string pathToProgramFiles = Environment.GetEnvironmentVariable("ProgramFiles"); string pathToTempFiles = Path.GetTempPath(); string pathToAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string pathToAppDataLocal = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string pathToDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); dictPathIdentifiers.Add("%PROGRAM_FILES%", pathToProgramFiles); dictPathIdentifiers.Add("%TEMP%", pathToTempFiles); dictPathIdentifiers.Add("%APP_DATA%", pathToAppData); dictPathIdentifiers.Add("%APP_DATA_LOCAL%", pathToAppDataLocal); dictPathIdentifiers.Add("%DOCUMENTS%", pathToDocuments); // ======================================= // STARCRAFT II // ======================================= // Install Path + add modifyregistry string pathToStarcraft2Folder = ""; ModifyRegistry mysc2Registry = new ModifyRegistry(); mysc2Registry.SubKey = "Software\\Blizzard Entertainment\\Starcraft II\\"; mysc2Registry.ShowError = true; // 1a. Try Registry LocalMachine pathToStarcraft2Folder = mysc2Registry.Read("InstallPath"); // 1b. Try Registry CurrentUser if (string.IsNullOrEmpty(pathToStarcraft2Folder)) { mysc2Registry.BaseRegistryKey = Registry.CurrentUser; pathToStarcraft2Folder = mysc2Registry.Read("InstallPath"); } if (string.IsNullOrEmpty(pathToStarcraft2Folder)) { pathToStarcraft2Folder = ""; } // 2. Try Default Path if (string.IsNullOrEmpty(pathToStarcraft2Folder)) { string sc2_defaultPath = pathToProgramFiles + "/" + "StarCraft II/"; if (File.Exists(pathToProgramFiles + "StarCraft II.exe")) pathToStarcraft2Folder = sc2_defaultPath; } // 3. Try Default Path (Beta) if (string.IsNullOrEmpty(pathToStarcraft2Folder)) { string defaultPath = pathToProgramFiles + "/" + "StarCraft II Beta/"; if (File.Exists(pathToProgramFiles + "StarCraft II.exe")) pathToStarcraft2Folder = defaultPath; } dictPathIdentifiers.Add("%SC2_INSTALL_PATH%", pathToStarcraft2Folder); // ======================================= // STARCRAFT I // (no registry key to my knowledge) // ^-- (well there is!) // ======================================= //Installpath + modify reg string pathToStarcraft1Folder = ""; ModifyRegistry mysc1Registry = new ModifyRegistry(); mysc1Registry.SubKey = "Software\\Blizzard Entertainment\\Starcraft\\"; mysc1Registry.ShowError = true; // 1a. Try Registry LocalMachine (no idea if localmachine is used, dont think so, but i let it stay) pathToStarcraft1Folder = mysc1Registry.Read("InstallPath"); // 1b. Try Registry CurrentUser if (string.IsNullOrEmpty(pathToStarcraft1Folder)) { mysc1Registry.BaseRegistryKey = Registry.CurrentUser; pathToStarcraft1Folder = mysc1Registry.Read("InstallPath"); } if (string.IsNullOrEmpty(pathToStarcraft1Folder)) { pathToStarcraft1Folder = ""; } // 2. Try Default Path if (string.IsNullOrEmpty(pathToStarcraft1Folder)) { string sc1_defaultPath = pathToProgramFiles + "/" + "StarCraft/"; if (File.Exists(pathToProgramFiles + "StarCraft.exe")) pathToStarcraft1Folder = sc1_defaultPath; } dictPathIdentifiers.Add("%SC1_INSTALL_PATH%", pathToStarcraft1Folder); //===================== //Warcraft 3 //===================== //Install path + modifyreg string pathToWarcraft3Folder = ""; ModifyRegistry mywc3Registry = new ModifyRegistry(); mywc3Registry.SubKey = "Software\\Blizzard Entertainment\\Warcraft III\\"; mywc3Registry.ShowError = true; // 1a. Try Registry LocalMachine (no idea if localmachine is used, dont think so, but i let it stay) pathToWarcraft3Folder = mywc3Registry.Read("InstallPath"); // 1b. Try Registry CurrentUser if (string.IsNullOrEmpty(pathToWarcraft3Folder)) { mywc3Registry.BaseRegistryKey = Registry.CurrentUser; pathToWarcraft3Folder = mywc3Registry.Read("InstallPath"); } if (string.IsNullOrEmpty(pathToWarcraft3Folder)) { pathToWarcraft3Folder = ""; } dictPathIdentifiers.Add("%WC3_INSTALL_PATH%", pathToWarcraft3Folder); }
public bool init() { try { this.Text = "BeanfunLogin - v" + Properties.Settings.Default.currentVersion.ToString().Insert(1, ".").Insert(3, "."); this.AcceptButton = this.button1; this.bfClient = null; //Properties.Settings.Default.Reset(); //SetToDefault. // Handle settings. if (Properties.Settings.Default.rememberAccount == true) this.textBox1.Text = Properties.Settings.Default.AccountID; if (Properties.Settings.Default.rememberPwd == true && Properties.Settings.Default.loginMethod != 2) { this.checkBox1.Enabled = false; // Load password. if (File.Exists("UserState.dat")) { Byte[] cipher = File.ReadAllBytes("UserState.dat"); string entropy = Properties.Settings.Default.entropy; byte[] plaintext = ProtectedData.Unprotect(cipher, Encoding.UTF8.GetBytes(entropy), DataProtectionScope.CurrentUser); this.textBox2.Text = System.Text.Encoding.UTF8.GetString(plaintext); } } if (Properties.Settings.Default.autoLogin == true && Properties.Settings.Default.loginMethod != 2 && Properties.Settings.Default.loginMethod != 4) { this.UseWaitCursor = true; this.panel2.Enabled = false; this.button1.Text = "請稍後..."; this.backgroundWorker2.RunWorkerAsync(Properties.Settings.Default.loginMethod); } if (Properties.Settings.Default.gamePath == "") { ModifyRegistry myRegistry = new ModifyRegistry(); myRegistry.BaseRegistryKey = Registry.CurrentUser; myRegistry.SubKey = "Software\\Gamania\\MapleStory"; if (myRegistry.Read("Path") != "") Properties.Settings.Default.gamePath = myRegistry.Read("Path"); } this.comboBox1.SelectedIndex = Properties.Settings.Default.loginMethod; this.comboBox2.SelectedIndex = Properties.Settings.Default.loginGame; this.textBox3.Text = ""; if (this.textBox1.Text == "") this.ActiveControl = this.textBox1; else if (this.textBox2.Text == "") this.ActiveControl = this.textBox2; // .NET textbox full mode bug. this.textBox1.ImeMode = ImeMode.OnHalf; this.textBox2.ImeMode = ImeMode.OnHalf; return true; } catch { return errexit("初始化失敗,未知的錯誤。", 0); } }
private void button4_Click(object sender, EventArgs e) { RegistryKey bk = Registry.ClassesRoot; RegistryKey sk = bk.CreateSubKey("*\\shell\\RightClickDeposit"); ModifyRegistry reg = new ModifyRegistry(); reg.BaseRegistryKey = bk; reg.SubKey = "*\\shell\\RightClickDeposit"; reg.Write("MUIVerb", "Deposit to"); reg.Write("Icon", Application.StartupPath + "\\icons\\rcd.ico"); string commandList = ""; foreach(KeyValuePair<int,Profile> p in profiles) { if (p.Value.IsDefault()) { string commandName = "RightClickDeposit.deposit." + p.Value.GetId(); commandList += commandName + "; "; RegistryKey cbk = Registry.LocalMachine; RegistryKey ck = cbk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\" + commandName); ModifyRegistry regcmd = new ModifyRegistry(); regcmd.BaseRegistryKey = cbk; regcmd.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\" + commandName; regcmd.Write("MUIVerb", p.Value.GetName()); regcmd.Write("Icon", Application.StartupPath + "\\icons\\add.ico"); //MessageBox.Show(regcmd.Read("MUIVerb")); RegistryKey cck = cbk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\" + commandName + "\\command"); regcmd.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\" + commandName + "\\command"; regcmd.Write("", Application.StartupPath + "\\RightClickDeposit.exe " + p.Value.GetId() + " create \"%1\""); } } RegistryKey ubk = Registry.LocalMachine; RegistryKey uk = ubk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.update"); ModifyRegistry regu = new ModifyRegistry(); regu.BaseRegistryKey = ubk; regu.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.update"; regu.Write("MUIVerb", "Update or delete previous deposits"); regu.Write("Icon", Application.StartupPath + "\\icons\\update.ico"); RegistryKey cuk = ubk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.update\\command"); regu.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.update\\command"; regu.Write("", Application.StartupPath + "\\RightClickDeposit.exe 0 update \"%1\""); RegistryKey pbk = Registry.LocalMachine; RegistryKey pk = pbk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.profiles"); ModifyRegistry regp = new ModifyRegistry(); regp.BaseRegistryKey = pbk; regp.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.profiles"; regp.Write("MUIVerb", "Manage profiles (admin-only)"); regp.Write("Icon", Application.StartupPath + "\\icons\\manage.ico"); RegistryKey puk = pbk.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.profiles\\command"); regp.SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CommandStore\\shell\\RightClickDeposit.profiles\\command"; regp.Write("", Application.StartupPath + "\\RightClickDeposit.exe profiles"); commandList += "RightClickDeposit.update; RightClickDeposit.profiles"; reg.Write("SubCommands", commandList); MessageBox.Show("Right-click explorer context menus updated successfully", "Menu update successful"); }
//stroe the token in registry private void StroeToken(string keyName, string keyValue) { try { ModifyRegistry myRegistry = new ModifyRegistry(); //myRegistry.SubKey = "SOFTWARE\\RTF_SHARP_EDIT\\RECENTFILES"; myRegistry.ShowError = true; myRegistry.DeleteSubKeyTree(); myRegistry.Write(keyName, keyValue); LogHelper.Debug(String.Format("Stroed token: {0} in registry with subkey: {1} and key name: {2}", keyValue, myRegistry.SubKey, keyName)); } catch (Exception ex) { LogHelper.Error(ex); } }
//get the token from registry private string RetrieveToken(string keyName) { try { ModifyRegistry myRegistry = new ModifyRegistry(); //myRegistry.SubKey = "SOFTWARE\\RTF_SHARP_EDIT\\RECENTFILES"; myRegistry.ShowError = true; string token = myRegistry.Read(keyName); LogHelper.Debug(String.Format("Get token: {0} in registry with subkey: {1} and key name: {2}", token, myRegistry.SubKey, keyName)); return token; } catch (Exception ex) { LogHelper.Error(ex); return null; } }
private void customBuildToolStripMenuItem_Click(object sender, EventArgs e) { //Try to build if (this.CurrentProject != null) { Emulator.Instance.Dispose(); this.IsCustomBuild = true; float XRatio = 0; float YRatio = 0; if (this.CurrentProject.Orientation == CoronaGameProject.OrientationScreen.Portrait) { XRatio = (float)this.currentTargetResolution.Resolution.Width / (float)this.CurrentProject.width; YRatio = (float)this.currentTargetResolution.Resolution.Height / (float)this.CurrentProject.height; } else { YRatio = (float)this.currentTargetResolution.Resolution.Width / (float)this.CurrentProject.width; XRatio = (float)this.currentTargetResolution.Resolution.Height / (float)this.CurrentProject.height; } //Refresh sceneLuaCodes string filePathSelectedInEditor = ""; if (this.cgEeditor1.ActiveDocument != null) { filePathSelectedInEditor = this.cgEeditor1.ActiveDocument.FilePath; } for (int i = 0; i < this.CurrentProject.Scenes.Count; i++) { Scene scene = this.CurrentProject.Scenes[i]; this.cgEeditor1.RefreshSceneLuaCode(scene, true, XRatio, YRatio); } if(!filePathSelectedInEditor.Equals("")) this.cgEeditor1.OpenFileInEditor(filePathSelectedInEditor); if (this.mainBackWorker.IsBusy == true) this.mainBackWorker.CancelAsync(); if (this.mainBackWorker.IsBusy == false) { //this.Enabled = false; this.isFormLocked = true; string device = this.currentTargetResolution.TargetDevice.Replace(" ", ""); ModifyRegistry myRegistry = new ModifyRegistry(); myRegistry.SubKey = "Software\\Ansca Corona\\Corona Simulator\\Preferences"; myRegistry.ShowError = true; myRegistry.Write("Device", device); if(this.CurrentProject.Orientation == CoronaGameProject.OrientationScreen.Landscape) { //regKey.SetValue("Zoom", unchecked((int)0xf0000000u), Re.DWord); //string hex = "fffffffe"; //var result = new byte[hex.Length/2]; //for (int i = 0; i < hex.Length; i += 2) //{ // result[i / 2] = byte.Parse(hex.Substring(i, 2), System.Globalization.NumberStyles.HexNumber); //} myRegistry.Write("Zoom", unchecked((int)0xfffffffdu)); } this.currentWorkerAction = "ACTION_BUILD_PLAY"; this.mainBackWorker.RunWorkerAsync(this.currentWorkerAction); } } }