Represents a view on the registry as imposed by the registry redirector.
This is a static respresentation based on the information at: http://msdn.microsoft.com/en-us/library/windows/desktop/aa384253(v=vs.85).aspx.
Example #1
0
        public void MapKeyPathsIn64BitProcess()
        {
            var view = new RegistryView(true);
            Assert.IsTrue(view.Is64Bit);

            // Invalid paths.
            Assert.IsNull(view.MapKeyPath(null));
            Assert.IsNull(view.MapKeyPath("TRE"));
            Assert.IsNull(view.MapKeyPath("TEST"));

            // 32-bit paths.
            Assert.AreEqual(@"HKEY_CLASSES_ROOT\Wow6432Node\CLSID\", view.MapKeyPath(@"00:\CLSID\"), true);
            Assert.AreEqual(@"HKEY_CURRENT_USER\Software\Wow6432Node\Classes\CLSID\", view.MapKeyPath(@"01:\Software\Classes\CLSID\"), true);
            Assert.AreEqual(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\TEST\", view.MapKeyPath(@"02:\Software\TEST\"), true);
            Assert.AreEqual(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\", view.MapKeyPath(@"02:\Software\Microsoft\"), true);
            Assert.AreEqual(@"HKEY_LOCAL_MACHINE\Software\Microsoft\EventSystem\", view.MapKeyPath(@"02:\Software\Microsoft\EventSystem\"), true);
            Assert.AreEqual(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\TEST\", view.MapKeyPath(@"02:\Software\Wow6432Node\TEST\"), true);
            Assert.AreEqual(@"HKEY_USERS\S-1-5-18\Software\Wow6432Node\Classes\CLSID\", view.MapKeyPath(@"03:\S-1-5-18\Software\Classes\CLSID\"), true);

            // 64-bit paths.
            Assert.AreEqual(@"HKEY_CLASSES_ROOT\CLSID\", view.MapKeyPath(@"20:\CLSID\"), true);
            Assert.AreEqual(@"HKEY_CURRENT_USER\Software\Classes\CLSID\", view.MapKeyPath(@"21:\Software\Classes\CLSID\"), true);
            Assert.AreEqual(@"HKEY_LOCAL_MACHINE\Software\TEST\", view.MapKeyPath(@"22:\Software\TEST\"), true);
            Assert.AreEqual(@"HKEY_LOCAL_MACHINE\Software\Microsoft\", view.MapKeyPath(@"22:\Software\Microsoft\"), true);
            Assert.AreEqual(@"HKEY_LOCAL_MACHINE\Software\Microsoft\EventSystem\", view.MapKeyPath(@"22:\Software\Microsoft\EventSystem\"), true);
            Assert.AreEqual(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\TEST\", view.MapKeyPath(@"22:\Software\Wow6432Node\TEST\"), true);
            Assert.AreEqual(@"HKEY_USERS\S-1-5-18\Software\Classes\CLSID\", view.MapKeyPath(@"23:\S-1-5-18\Software\Classes\CLSID\"), true);
        }
Example #2
0
        public void SingletonMatchesArchitecture()
        {
            var view = RegistryView.GetInstance();

            Assert.AreEqual <bool>(8 == IntPtr.Size, view.Is64Bit);
        }
Example #3
0
 public static void Initialize(TestContext context)
 {
     // Initialize to avoid showing perf hit to individual tests.
     RegistryView.GetInstance();
 }
Example #4
0
        /// <summary>
        /// Gets the single instance for the current process bitness.
        /// </summary>
        /// <returns></returns>
        internal static RegistryView GetInstance()
        {
            if (null == instance)
            {
                lock (syncRoot)
                {
                    if (null == instance)
                    {
                        instance = new RegistryView(8 == IntPtr.Size);
                    }
                }
            }

            return instance;
        }