public void SetRegistryKeyValueTest()
        {
            string keyName  = "TestKey";
            string keyValue = "TestKeyValue";

            RegeditHelper.SetRegistryKeyValue(keyName, keyValue);

            string testResultValue = Registry.LocalMachine.OpenSubKey("SOFTWARE")
                                     .OpenSubKey(RegeditHelper.COMPANY_NAME)?.OpenSubKey(RegeditHelper.PRODUCT_NAME)?.GetValue(keyName).ToString();

            Registry.LocalMachine.DeleteSubKeyTree(RegeditHelper.COMPANY_NAME, false);

            Assert.Equal(keyValue, testResultValue);
        }
Beispiel #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int result = RegeditHelper.CheckRegedit();

            if (result < 0)
            {
                return;
            }
            else
            {
                string winName = ((Button)e.OriginalSource).Tag.ToString();
                Window win     = ((Window)_assembly.CreateInstance(string.Format("MvvmLight4.View.{0}", winName)));
                win.Owner = this;
                win.ShowDialog();
            }
        }
Beispiel #3
0
        private void ReadUSBState()
        {
            var ret = RegeditHelper.ReadUSBState();

            if (ret == true)
            {
                TextBlock_USBState.Text = "启用";
            }
            else if (ret == false)
            {
                TextBlock_USBState.Text = "禁用";
            }
            else
            {
                TextBlock_USBState.Text = "读取USB状态需要系统管理员权限";
            }
        }
Beispiel #4
0
        private void ExecuteLoadedCmd()
        {
            //写注册表
            bool isSdSuccess = RegeditHelper.SetRegedit("Sd", "MjAxOS0wOC0zMQ==");
            bool isStSuccess = RegeditHelper.SetRegedit("St", "bm9ybWFs");

            if (!isSdSuccess || !isStSuccess)
            {
                MessageBox.Show("权限不足,请使用管理员权限运行程序");
                return;
            }

            string dbName = "data.sqlite";

            if (!File.Exists(dbName))
            {
                Console.WriteLine("数据库不存在");
                int result = InitService.GetService().InitDatabase(dbName);
                if (result < 0)
                {
                    Console.WriteLine("创建出错");
                }
                else
                {
                    Console.WriteLine("创建成功:{0}", result);
                }
            }

            //判断最后一次任务是否有未查看的异常项目
            int lastTaskId = TaskService.GetService().GetLastTaskId();

            if (lastTaskId >= 0)
            {
                //判断本次任务是否有未查看的任务
                int videoNotWatched = AbnormalService.GetService().SearchLastTaskById(lastTaskId);
                if (videoNotWatched > 0)
                {
                    //存在未观看项目
                    //通过消息机制弹出提示
                    Messenger.Default.Send(videoNotWatched, "videoNotWatched");
                }
            }
        }
 public SyncConfigManage()
 {
     regHelper = new RegeditHelper();
 }
 public SyncConfigManage()
 {
     regHelper = new RegeditHelper();
 }
Beispiel #7
0
 protected override void OnStart(string[] args)
 {
     RegeditHelper.SetRegistryKeyValue("URL", "localhost");
 }
Beispiel #8
0
 private void Button_DisabledUSB_Click(object sender, RoutedEventArgs e)
 {
     RegeditHelper.RegToStopUSB();
     ReadUSBState();
 }