I wrote three programs that modifies the registry in Windows Mobile to install and remove a todayscreen plugin for debugging purposes. They worked great for a while, but one by one they have suddenly been giving "UnauthorizedAccessException"s.
See the code for two of the programs below (note that the following code just sits directly in Main, so it runs and then the program terminates)...
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);
The third program was a configuration program that had options to add and remove the registry keys using exact copies of the code above, but it never quite worked. For a while it could run the code for "RegistryInit", but that didn't last long. Now the original "RegistryClear" program doesn't work, giving the same UnauthorizedAccessException. I find it very weird that these programs worked find for a while, then suddenly have stopped working.
Any ideas?