예제 #1
0
        public static IPreviewHandler InitalizePreviewHandler(FileInfoEx file)
        {
            IPreviewHandler retVal    = null;
            PreviewerInfo   previewer = getPreviewer(file.FullName);

            if (previewer != null)
            {
                bool   isInitialized = false;
                Type   a             = Type.GetTypeFromCLSID(previewer.CLSID, true);
                object o             = Activator.CreateInstance(a);

                IInitializeWithFile   fileInit   = o as IInitializeWithFile;
                IInitializeWithStream streamInit = o as IInitializeWithStream;

                if (fileInit != null)
                {
                    fileInit.Initialize(file.FullName, 0);
                    isInitialized = true;
                }
                else if (streamInit != null)
                {
                    FileStreamEx stream = file.OpenRead();
                    streamInit.Initialize((IStream)stream, 0);
                    isInitialized = true;
                }

                if (isInitialized)
                {
                    retVal = o as IPreviewHandler;
                }
            }
            return(retVal);
        }
예제 #2
0
        static void loadPreviewerList()
        {
            List <PreviewerInfo> previewerList = new List <PreviewerInfo>();

            using (RegistryKey rk =
                       Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers"))
            {
                if (rk != null)
                {
                    string[] guids = rk.GetValueNames();

                    for (int i = 0; i < guids.Length; i++)
                    {
                        bool repeated = false;
                        foreach (PreviewerInfo curPrv in previewerList)
                        {
                            if (curPrv.CLSID.ToString() == guids[i])
                            {
                                repeated = true;
                            }
                        }
                        if (repeated)
                        {
                            break;
                        }

                        PreviewerInfo prv = new PreviewerInfo();
                        prv.CLSID = new Guid(guids[i]);
                        prv.Title = rk.GetValue(guids[i]).ToString();

                        previewerList.Add(prv);
                    }
                }
            }

            CurrentPreviewers = new List <PreviewerInfo>(previewerList);
        }
예제 #3
0
        static void loadPreviewerList()
        {
            List<PreviewerInfo> previewerList = new List<PreviewerInfo>();

            using (RegistryKey rk =
                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers"))
            {
                if (rk != null)
                {
                    string[] guids = rk.GetValueNames();

                    for (int i = 0; i < guids.Length; i++)
                    {
                        bool repeated = false;
                        foreach (PreviewerInfo curPrv in previewerList)
                            if (curPrv.CLSID.ToString() == guids[i])
                                repeated = true;
                        if (repeated)
                            break;

                        PreviewerInfo prv = new PreviewerInfo();
                        prv.CLSID = new Guid(guids[i]);
                        prv.Title = rk.GetValue(guids[i]).ToString();

                        previewerList.Add(prv);
                    }
                }

            }

            CurrentPreviewers = new List<PreviewerInfo>(previewerList);
        }