Example #1
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();
     }
 }
Example #2
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);
        }