修改注册表,使系统重启并进入系统前出现对话框显示提示信息

在注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon下,修改LegalNoticeCaption和LegalNoticeText的值,在系统启动且未登录系统前会根据这两个值显示提示信息。

在C#中访问注册表用到Registry和RegistryKey两个类。

Registry类主要是指定要操作的主注册表主键,如HKEY_LOCAL_MACHINE,HKEY_CURRENT_USER等。

RegistryKey类主要是进行注册表的操作。此类下面的CreateSubKey用来创建其下的子键。SetValue用是写入子键下面的 名称/值。RegistryValueKind是指写入值的类型。

C#中要引用Microsoft.Win32单元集。

如下:

 private void button1_Click(object sender, EventArgs e)
        {
            RegistryKey rkey = Registry.LocalMachine;
            RegistryKey rkeyinfo = rkey.CreateSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon");
            rkeyinfo.SetValue("LegalNoticeCaption", textBox1.Text,RegistryValueKind.String);
            rkeyinfo.SetValue("LegalNoticeText", textBox2.Text,RegistryValueKind.String);
            MessageBox.Show("已设计完毕,请重新启动计算机.", "提示", MessageBoxButtons.OK);

        }

 

 

posted on 2012-12-20 09:22  天上星  阅读(515)  评论(0编辑  收藏  举报

导航