进入Windows之前发出警告

实现效果:

  

知识运用:

  通过注册表中HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\子键下的LegalNoticeCaptionLegalNoticeText项的值

来实现

RegistryKey类的CreateSubKey    SetValue方法

  public RegistryKey CreateSubKey (string  subkey)  //创建一个或打开一个子项进行写访问

    //使用指定的注册表数据类型设置注册表中的名称/值对的值

      //name:存储的值名称  value:存储的数据  valueKind:存储是使用的注册表数据类型

  public void SetValue  (string name ,Object value ,RegistryValueKind  valueKind)

补:使用RegistryKey和Registry类时  引用  Microsoft. Win32

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            RegistryKey rkey = Registry.LocalMachine;               //获取注册表中的LocalMachine节点
            RegistryKey rinfo = rkey.CreateSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon");  //创建注册表项
            rinfo.SetValue("LegalNoticeCaption",textBox1.Text,RegistryValueKind.String);                    //设置键
            rinfo.SetValue("LegalNoticeText",textBox2.Text,RegistryValueKind.String);                       //设置值
            MessageBox.Show("设置成功!请重新启动","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }

  

猜你喜欢

转载自www.cnblogs.com/feiyucha/p/10302178.html