Ejemplo n.º 1
0
        public void TestGlobalKeys()
        {
            Microsoft.Win32.RegistryKey classes, currentconfig, currentuser, dyndata, localmachine, perfdata, users;
            Microsoft.VisualBasic.MyServices.RegistryProxy registry = getProxy();

            classes = registry.ClassesRoot;
            Assert.AreEqual("HKEY_CLASSES_ROOT", classes.Name, "ClassesRoot");

            currentconfig = registry.CurrentConfig;
            Assert.AreEqual("HKEY_CURRENT_CONFIG", currentconfig.Name, "CurrentConfig");

            currentuser = registry.CurrentUser;
            Assert.AreEqual("HKEY_CURRENT_USER", currentuser.Name, "CurrentUser");

            dyndata = registry.DynData;
            Assert.AreEqual("HKEY_DYN_DATA", dyndata.Name, "DynData");

            localmachine = registry.LocalMachine;
            Assert.AreEqual("HKEY_LOCAL_MACHINE", localmachine.Name, "LocalMachine");

            perfdata = registry.PerformanceData;
            Assert.AreEqual("HKEY_PERFORMANCE_DATA", perfdata.Name, "PerformanceData");

            users = registry.Users;
            Assert.AreEqual("HKEY_USERS", users.Name, "Users");
        }
Ejemplo n.º 2
0
 public void TestGetValue()
 {
     try {
         Microsoft.VisualBasic.MyServices.RegistryProxy registry = getProxy();
         object value = registry.GetValue("HKEY_CLASSES_ROOT", ".txt", "a");
         Assert.AreEqual("a", value, "#01");
     } catch (System.Security.SecurityException ex) {
         Assert.Ignore(ex.Message);
     }
 }
Ejemplo n.º 3
0
        public void TestSetValue2()
        {
            try {
                Microsoft.VisualBasic.MyServices.RegistryProxy registry = getProxy();
                string name      = ".someweirdthing";
                string keyname   = "HKEY_CLASSES_ROOT\\" + name;
                string valuename = ".name";
                registry.SetValue(keyname, valuename, 1);
                object value = registry.GetValue(keyname, valuename, 2);
                Assert.AreEqual(1, value, "#01");
                registry.SetValue(keyname, valuename, 3, Microsoft.Win32.RegistryValueKind.DWord);
                value = registry.GetValue(keyname, valuename, 3);
                Assert.AreEqual(3, value, "#02");

                registry.ClassesRoot.DeleteSubKey(name);
            } catch (System.Security.SecurityException ex) {
                Assert.Ignore(ex.Message);
            }
        }