/// <summary>
        /// Read the registry to learn about the preview handlers that are available on this machine
        /// Return a structure containing 2 collections.  One of all the file extensions and whether we found a preview handler
        /// registered, and one of the preview handlers and their CLSIDs
        /// </summary>
        internal static RegistrationData LoadRegistrationInformation()
        {
            // Load and sort all preview handler information from registry
            List<PreviewHandlerInfo> handlers = new List<PreviewHandlerInfo>();
            using (RegistryKey handlersKey = Registry.LocalMachine.OpenSubKey(
                BaseRegistryKey))
            {
                foreach (string id in handlersKey.GetValueNames())
                {
                    PreviewHandlerInfo handler = new PreviewHandlerInfo();
                    handler.ID = id;
                    handler.Name = handlersKey.GetValue(id, null) as string;
                    handlers.Add(handler);
                }
            }
            handlers.Sort(delegate(PreviewHandlerInfo first, PreviewHandlerInfo second)
            {
                if (first.Name == null) return 1;
                else if (second.Name == null) return -1;
                else return first.Name.CompareTo(second.Name);
            });

            // Create a lookup table of preview handler ID -> PreviewHandlerInfo
            Dictionary<string, PreviewHandlerInfo> handlerMapping = new Dictionary<string, PreviewHandlerInfo>(handlers.Count);
            foreach (PreviewHandlerInfo handler in handlers)
            {
                handlerMapping.Add(handler.ID, handler);
            }

            // Get all classes/extensions from registry
            string[] extensions = Registry.ClassesRoot.GetSubKeyNames();

            // Find out what each extension is registered to be previewed with
            List<ExtensionInfo> extensionInfos = new List<ExtensionInfo>(extensions.Length);
            foreach (string extension in extensions)
            {
                if (extension.StartsWith("."))
                {
                    ExtensionInfo info = new ExtensionInfo();
                    info.Extension = extension;

                    string id = Registry.GetValue(
                        string.Format(BaseClsIDKey, extension),
                        null, null) as string;
                    if (id == null)
                        id = Registry.GetValue(
                        string.Format(BaseClsIdKey2, extension),
                        null, null) as string;
                    PreviewHandlerInfo mappedHandler;
                    if (id != null && handlerMapping.TryGetValue(id, out mappedHandler)) info.Handler = mappedHandler;

                    extensionInfos.Add(info);
                }
            }

            // Return the information
            RegistrationData data = new RegistrationData();
            data.Handlers = handlers;
            data.Extensions = extensionInfos;
            return data;
        }
        /// <summary>
        /// Read the registry to learn about the preview handlers that are available on this machine
        /// Return a structure containing 2 collections.  One of all the file extensions and whether we found a preview handler
        /// registered, and one of the preview handlers and their CLSIDs
        /// </summary>
        internal static RegistrationData LoadRegistrationInformation()
        {
            // Load and sort all preview handler information from registry
            List <PreviewHandlerInfo> handlers = new List <PreviewHandlerInfo>();

            using (RegistryKey handlersKey = Registry.LocalMachine.OpenSubKey(
                       BaseRegistryKey))
            {
                foreach (string id in handlersKey.GetValueNames())
                {
                    PreviewHandlerInfo handler = new PreviewHandlerInfo();
                    handler.ID   = id;
                    handler.Name = handlersKey.GetValue(id, null) as string;
                    handlers.Add(handler);
                }
            }
            handlers.Sort(delegate(PreviewHandlerInfo first, PreviewHandlerInfo second)
            {
                if (first.Name == null)
                {
                    return(1);
                }
                else if (second.Name == null)
                {
                    return(-1);
                }
                else
                {
                    return(first.Name.CompareTo(second.Name));
                }
            });

            // Create a lookup table of preview handler ID -> PreviewHandlerInfo
            Dictionary <string, PreviewHandlerInfo> handlerMapping = new Dictionary <string, PreviewHandlerInfo>(handlers.Count);

            foreach (PreviewHandlerInfo handler in handlers)
            {
                handlerMapping.Add(handler.ID, handler);
            }

            // Get all classes/extensions from registry
            string[] extensions = Registry.ClassesRoot.GetSubKeyNames();

            // Find out what each extension is registered to be previewed with
            List <ExtensionInfo> extensionInfos = new List <ExtensionInfo>(extensions.Length);

            foreach (string extension in extensions)
            {
                if (extension.StartsWith("."))
                {
                    ExtensionInfo info = new ExtensionInfo();
                    info.Extension = extension;

                    string id = Registry.GetValue(
                        string.Format(BaseClsIDKey, extension),
                        null, null) as string;
                    if (id == null)
                    {
                        id = Registry.GetValue(
                            string.Format(BaseClsIdKey2, extension),
                            null, null) as string;
                    }
                    PreviewHandlerInfo mappedHandler;
                    if (id != null && handlerMapping.TryGetValue(id, out mappedHandler))
                    {
                        info.Handler = mappedHandler;
                    }

                    extensionInfos.Add(info);
                }
            }

            // Return the information
            RegistrationData data = new RegistrationData();

            data.Handlers   = handlers;
            data.Extensions = extensionInfos;
            return(data);
        }