我更新了一个注册表项以禁用文件夹选项,但它在注销并登录 Windows 后生效,或者我编写了一个重新启动explorer
进程的函数,每次更改选项时重新启动资源管理器进程都不好.. .我听说过WMI Windows管理工具,我已经搜索过这个但是,我找不到我需要的东西..我的实际代码是:
RegistryKey rk = Registry.CurrentUser;
RegistryKey sk1,sk2;
private void Form1_Load(object sender, EventArgs e)
{
domainUpDown1.SelectedIndex = 0;
#region Start Check for Folder Options
sk1 = rk.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\");
dfo = sk1.GetValue("NoFolderOptions", "No Key").ToString();
if (dfo == "No Key")
{
sk1.SetValue("NoFolderOptions", 0);
button1.Text = "Disable Folder Options";
}
else if (dfo == "0")
{
button1.Text = "Disable Folder Options";
}
else if (dfo == "1")
{
button1.Text = "Enable Folder Options";
}
#endregion
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text=="Enable Folder Options")
{
sk1.SetValue("NoFolderOptions", 0, RegistryValueKind.DWord);
button1.Text = "Disable Folder Options";
}
else if (button1.Text == "Disable Folder Options")
{
sk1.SetValue("NoFolderOptions", 1,RegistryValueKind.DWord);
button1.Text = "Enable Folder Options";
}
}
我添加了代码以立即更新注册表。其中包含SendMessage
等,...