我写了三个程序,修改Windows Mobile中的注册表以安装和删除用于调试目的的todayscreen插件。他们工作了一段时间,但他们一个接一个地突然给了“UnauthorizedAccessException”。Windows Mobile Registry UnauthorizedAccessException
看到代码了两个下方(注意,下面的代码干脆直接坐在主,所以它运行,然后程序终止)的节目...
RegistryInit.exe:
RegistryKey CustomItem = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Today\Items\TodayLauncher");
CustomItem.SetValue("Type", 4, RegistryValueKind.DWord);
CustomItem.SetValue("Enabled", 1, RegistryValueKind.DWord);
CustomItem.SetValue("Options", 1, RegistryValueKind.DWord);
CustomItem.SetValue("DLL", @"\Program Files\TodayLauncher\TodayLauncher.dll", RegistryValueKind.String);
CustomItem.SetValue("Config", @"\Program Files\TodayLauncher\Settings.cfg", RegistryValueKind.String);
CustomItem.SetValue("Selectability", 1, RegistryValueKind.DWord);
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
RegistryClear:
Microsoft.Win32.Registry.LocalMachine.DeleteSubKey(@"Software\Microsoft\Today\Items\TodayLauncher");
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
第三个方案是,有选择,添加和删除使用上面的代码的精确副本的注册表项配置程序,但它NE很有效。有一段时间它可以运行“RegistryInit”的代码,但那不会持续太久。现在原来的“RegistryClear”程序不起作用,给出相同的UnauthorizedAccessException。我发现这些程序运行一段时间后很奇怪,然后突然停止工作。
任何想法?
我做了一些更多的google搜索,我发现这个职位... http://forum.xda-developers.com/showthread.php?t=498869 我添加了“真”到OpenSubKeys,但没有解决问题 – zort15 2009-05-17 19:21:36