コード例 #1
0
        private void WriteNote_FormClosed(object sender, FormClosedEventArgs e)
        {
            RegistryKey RegKey1, RegKey2;

            RegKey1 = Registry.CurrentUser;//获取当前用户注册表项
            try
            {
                RegKey2 = RegKey1.CreateSubKey(@"Software\NoteBook");//创建注册表子项
                RegKey2.SetValue("PointX", this.Location.X.ToString());
                RegKey2.SetValue("PointY", this.Location.Y.ToString());
            }
            catch { }

            WindowsAPI.AnimateWindow(this.Handle, 1000, WindowsAPI.AW_BLEND | WindowsAPI.AW_HIDE);
        }
コード例 #2
0
 private void frmMain_Load(object sender, EventArgs e)
 {
     isAdmin = IsUserAnAdmin();
     if (isAdmin == false)
     {
         MessageBox.Show("You don't have proper privileges level to make changes, administrators privileges are required", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Close();
     }
     else
     {
         notifyContextMenu.MenuItems.Add(0, new MenuItem("显示界面"));
         notifyContextMenu.MenuItems.Add(1, new MenuItem("退出"));
         notifyContextMenu.MenuItems[0].Click += Item1_Click;
         notifyContextMenu.MenuItems[1].Click += Item2_Click;
         this.notifyIcon1.ContextMenu          = notifyContextMenu;
         Regkey = Registry.LocalMachine.OpenSubKey(Regpath, true);
         Gvalue = Convert.ToInt32(Regkey.GetValue("Start"));
         //check the current state of the usb/whether is enabled or disabled
         if (Gvalue == 3)
         {
             rdoEnable.Checked = true;
         }
         else if (Gvalue == 4)
         {
             rdoDisable.Checked = true;
         }
         RegKey2 = Registry.LocalMachine.OpenSubKey(ReadAndWriteRegPath, true);
         try
         {
             tvalue = Convert.ToInt32(RegKey2.GetValue("WriteProtect"));
             if (tvalue == 1)
             {
                 RadioButtonreadonly.Checked = true;
             }
             else if (tvalue == 0)
             {
                 RadioButtonreadwrite.Checked = true;
             }
         }
         catch (NullReferenceException) { }
         rdoEnable.Checked            = true;
         RadioButtonreadwrite.Checked = true;
         btnOK.PerformClick();
     }
 }
コード例 #3
0
        private void WriteNote_Load(object sender, EventArgs e)
        {
            dh  = new DataHelper();
            tfb = new TestForBinary();

            RegistryKey RegKey1, RegKey2;

            RegKey1 = Registry.CurrentUser;//获取当前用户注册表项
            try
            {
                RegKey2       = RegKey1.CreateSubKey(@"Software\NoteBook");//创建注册表子项
                this.Location = new Point(Convert.ToInt16(RegKey2.GetValue("PointX")), Convert.ToInt16(RegKey2.GetValue("PointY")));
            }
            catch
            {
                this.Location = new Point(
                    (Screen.PrimaryScreen.WorkingArea.Width - this.Size.Width) / 2,
                    (Screen.PrimaryScreen.WorkingArea.Height - this.Size.Height) / 2);
            }

            this.Icon = Properties.Resources.Icon_book;
            pictureBox_min.BackColor   = Color.Transparent;
            pictureBox_close.BackColor = Color.Transparent;
            comboBox_weather.Items.Add("晴");
            comboBox_weather.Items.Add("阴");
            comboBox_weather.Items.Add("多云");
            comboBox_weather.Items.Add("雨");
            comboBox_weather.Items.Add("雪");
            comboBox_weather.SelectedIndex = 0;

            comboBox_mood.Items.Add("开心");
            comboBox_mood.Items.Add("郁闷");
            comboBox_mood.Items.Add("失落");
            comboBox_mood.Items.Add("无聊");
            comboBox_mood.SelectedIndex = 0;

            label_UserName.Text = GlobalParam.Active_User;
            WindowsAPI.AnimateWindow(this.Handle, 300, WindowsAPI.AW_CENTER | WindowsAPI.AW_ACTIVATE);
        }
コード例 #4
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     Regkey = Registry.LocalMachine.OpenSubKey(Regpath, true);
     Regkey.SetValue("Start", rValue);
     if (GroupBox2.Enabled == true)
     {
         RegKey2 = Registry.LocalMachine.OpenSubKey(ReadAndWriteRegPath2, true);
         RegKey2.CreateSubKey("StorageDevicePolicies");
         RegKey2 = Registry.LocalMachine.OpenSubKey(ReadAndWriteRegPath, true);
         RegKey2.SetValue("WriteProtect", rsvalue);
     }
     if ((rValue == 3) && (rsvalue == 1))
     {
         MessageBox.Show("USB 端口已启用,权限为只读");
     }
     else if ((rValue == 3) && (rsvalue == 0))
     {
         MessageBox.Show("USB 端口已启用,权限为读写");
     }
     else
     {
         MessageBox.Show("USB 端口已禁用");
     }
 }