代码如下:
using System;
using Microsoft.Win32;
class reg
{
static void Main()
{
RegistryKey key=Registry.CurrentUser;
RegistryKey key1=key.CreateSubKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key1.SetValue("NoFind",1);
key1.Close();
Console.Write("Press any key to continue.");
Console.Read();
}
}
编译没有错误,运行时出错,提示:
未处理的异常: System.IO.IOException: 指定的路径无效。 at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey)
at reg.Main()
using System;
using Microsoft.Win32;
class reg
{
static void Main()
{
RegistryKey key=Registry.CurrentUser;
RegistryKey key1=key.CreateSubKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
key1.SetValue("NoFind",1);
key1.Close();
Console.Write("Press any key to continue.");
Console.Read();
}
}
编译没有错误,运行时出错,提示:
未处理的异常: System.IO.IOException: 指定的路径无效。 at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
at Microsoft.Win32.RegistryKey.CreateSubKey(String subkey)
at reg.Main()
http://blog.csdn.net/chengking/archive/2005/10/29/519087.aspx
再帮我看下这个问题吧
我先运行了这段程序:
using System;
using Microsoft.Win32;class regmodify
{
static void Main()
{
RegistryKey key=Registry.CurrentUser;
RegistryKey key1=key.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer");
key1.SetValue("NoFind",1);//屏蔽"搜索"
key1.SetValue("NoSetFolders",1);//屏蔽"设置"中的"控制面板"和"打印机"
key1.SetValue("NoSetTaskBar",1);//屏蔽"设置"中的"任务栏和开始菜单"
key1.SetValue("NoRecentDocsMenu",1);//屏蔽"文档"
key1.SetValue("NoRun",1);//屏蔽"运行"
key1.SetValue("NoClose",1);//屏蔽"关闭系统"
key1.SetValue("NoLogOff",1);//屏蔽"注销"
key1.Close();
}
}
然后运行这段程序的时候出现了问题:
using System;
using Microsoft.Win32;class regdel
{
static void Main()
{
RegistryKey key=Registry.CurrentUser;
key.DeleteSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoRun");
}
}
未处理的异常: System.ArgumentException: 该子项不存在,因此无法删除子项目录树。
at Microsoft.Win32.RegistryKey.DeleteSubKey(String subkey, Boolean throwOnMis
singSubKey)
at Microsoft.Win32.RegistryKey.DeleteSubKey(String subkey)
at regdel.Main()