Exemplo n.º 1
0
        private static void RegisterFileType(string extensionType)
        {
            string id = "ilSFV-" + extensionType.ToUpper();
            FileAssociationInfo fai = new FileAssociationInfo("." + extensionType.ToLower());

            if (fai.Exists)
            {
                fai.Delete();
            }
            fai.Create(id);

            string path = Assembly.GetExecutingAssembly().Location;

            ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);

            if (pai.Exists)
            {
                pai.Delete();
            }

            pai.Create
            (
                string.Format("{0} File", extensionType.ToUpper()),
                new ProgramVerb("Open", path + " \"%1\"")
            );

            /*RegistryWrapper reg = new RegistryWrapper();
             * reg.Write(string.Format(@"{0}\shell\ilSFV", id), "MUIVerb", "ilSFV");
             * reg.Write(string.Format(@"{0}\shell\ilSFV", id), "MultiSelectModel", "Single");
             * reg.Write(string.Format(@"{0}\shell\ilSFV", id), "SubCommands", "ilsfv.verify");*/
        }
Exemplo n.º 2
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            TRE_Explorer.Properties.Settings.Default.OpenFolder = this.textBoxOpenFolder.Text;
            TRE_Explorer.Properties.Settings.Default.SaveFolder = this.textBoxSaveFolder.Text;

            switch (this.comboBoxDefaultView.SelectedItem.ToString())
            {
            case "Large Icons":
                TRE_Explorer.Properties.Settings.Default.DefaultView = View.LargeIcon;
                break;

            case "Small Icons":
                TRE_Explorer.Properties.Settings.Default.DefaultView = View.SmallIcon;
                break;

            case "List":
                TRE_Explorer.Properties.Settings.Default.DefaultView = View.List;
                break;

            case "Details":
                TRE_Explorer.Properties.Settings.Default.DefaultView = View.Details;
                break;
            }
            TRE_Explorer.Properties.Settings.Default.DetailsDisplaysFullPath = this.checkBoxDetailsPanePathDisplay.Checked;
            TRE_Explorer.Properties.Settings.Default.PromptForUpdates        = this.checkBoxPromptForUpdates.Checked;
            TRE_Explorer.Properties.Settings.Default.DisplayNotifyIcon       = this.checkBoxDisplayNotifyIcon.Checked;
            TRE_Explorer.Properties.Settings.Default.Save();

            for (Int32 index = 0; index < this.checkedListBoxFileTypes.Items.Count; index++)
            {
                FileAssociationInfo fileAssociationInfo = new FileAssociationInfo("." + this.checkedListBoxFileTypes.Items[index].ToString().ToLower());
                if (this.checkedListBoxFileTypes.GetItemChecked(index))
                {
                    if (!fileAssociationInfo.Exists)
                    {
                        fileAssociationInfo.Create("TRE Explorer");
                    }
                    else
                    {
                        fileAssociationInfo.ProgID = "TRE Explorer";
                    }
                }
                else
                {
                    if ((fileAssociationInfo.Exists) && (fileAssociationInfo.ProgID == "TRE Explorer"))
                    {
                        fileAssociationInfo.Delete();
                    }
                }
            }

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        public static void RegisterFileAssociation()
        {
            FileAssociationInfo fileInfo = new FileAssociationInfo(".cin");

            if (fileInfo.Exists)
            {
                fileInfo.Delete();
            }

            if (!fileInfo.Exists)
            {
                fileInfo.Create("YahooKeyKeyCin");
                fileInfo.ContentType  = "text/plain";
                fileInfo.OpenWithList = new string[] {
                    "CinInstaller.exe", "notepad.exe", "winword.exe"
                };
            }

            string currentLocale = CultureInfo.CurrentUICulture.Name;

            ProgramAssociationInfo programInfo = new ProgramAssociationInfo(fileInfo.ProgID);

            if (programInfo.Exists)
            {
                programInfo.Delete();
            }

            if (!programInfo.Exists)
            {
                string cinInstallerFilename = Application.StartupPath +
                                              Path.DirectorySeparatorChar + "CinInstaller.exe";

                string command     = cinInstallerFilename + " %1";
                string description = "Yahoo! KeyKey Input Method Table";

                if (currentLocale.Equals("zh-TW"))
                {
                    description = "Yahoo! \u5947\u6469\u8f38\u5165\u6cd5\u8868\u683c";
                }
                else if (currentLocale.Equals("zh-CN"))
                {
                    description = "Yahoo! \u5947\u6469\u8f93\u5165\u6cd5\u8868\u683c";
                }

                programInfo.Create(description, new ProgramVerb("Open", @command));
                programInfo.DefaultIcon         = new ProgramIcon(cinInstallerFilename, 1);
                programInfo.AlwaysShowExtension = true;
            }

            ProgramAssociationInfo uriInfo = new ProgramAssociationInfo("ykeykey");

            if (uriInfo.Exists)
            {
                uriInfo.Delete();
            }

            if (!uriInfo.Exists)
            {
                string urlHandlerFilename = Application.StartupPath +
                                            Path.DirectorySeparatorChar + "PhraseEditor.exe";

                string command     = urlHandlerFilename + " %1";
                string description = "URL:Yahoo! KeyKey User Phrase Protocol";

                if (currentLocale.Equals("zh-TW"))
                {
                    description = "URL:Yahoo! \u5947\u6469\u8f38\u5165\u6cd5\u52a0\u5b57\u52a0\u8a5e\u5354\u5b9a";
                }
                else if (currentLocale.Equals("zh-CN"))
                {
                    description = "URL:Yahoo! \u5947\u6469\u8f93\u5165\u6cd5\u52a0\u5b57\u52a0\u8bcd\u534f\u5b9a";
                }

                uriInfo.Create(description, new ProgramVerb("Open", @command));
                // uriInfo.DefaultIcon = new ProgramIcon(urlHandlerFilename, 1);
                uriInfo.IsURLProtocol = true;
            }
        }
Exemplo n.º 4
0
        private void btnTry_AssFileType_Click(object sender, RoutedEventArgs e)
        {
            //  CodeFile1.txt

            bool bDelFai = false;

            //FileAssociationInfo fai = new FileAssociationInfo(".bob");
            FileAssociationInfo fai = new FileAssociationInfo(".TryExt_2");

            if (!(fai.Exists))
            {
                //fai.Create("MyProgramName");
                fai.Create("TryExt_2_FileManager_ProgId");


                //Specify MIME type (optional)
                //fai.ContentType = "application/myfile";
                fai.ContentType = "TryExt_2_FileManager/TryExt_2_File";



                //Programs automatically displayed in open with list
                //fai.OpenWithList = new string[] { "notepad.exe", "wordpad.exe", "someotherapp.exe" };
                fai.OpenWithList = new string[] { "TryExt_FileManager.exe" };
            }
            else
            {
                bDelFai = true;
            }


//////////////////////////////////////////////////


            ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);

            if (!(pai.Exists))
            {
                pai.Create
                (
                    //Description of program/file type
                    "TryExt_FileManager's File Type",

                    new ProgramVerb
                    (
                        //Verb name
                        "Open",
                        //Path and arguments to use
                        //@"C:\SomePath\MyApp.exe %1"
                        @"E:\HthmWork\Projects\VS 2010\DocArchiver\TryExt_FileManager\bin\Debug\TryExt_FileManager.exe %1"
                    )
                );

                //optional
                //pai.DefaultIcon = new ProgramIcon(@"C:\SomePath\SomeIcon.ico");
                pai.DefaultIcon = new ProgramIcon(
                    //pai.Se.setde DefaultIcon = new ProgramIcon(
                    @"E:\HthmWork\Projects\VS 2010\DocArchiver\TryExt_FileManager\Icon1.ico");


                bDelFai = false;
            }
            else
            {
                pai.Delete();
                bDelFai = true;
            }

            if (bDelFai)
            {
                fai.Delete();
            }


            MessageBox.Show("Success !");
        }
Exemplo n.º 5
0
        private void SetFileAssociations()
        {
            //  CodeFile1.txt

            try
            {
                //throw new Exception("Try Exception.");


                string sDocArc_ProgId = "DocArchiver.DocMarkReader";

                {
                    //FileAssociationInfo fai = new FileAssociationInfo(".bob");
                    //FileAssociationInfo fai = new FileAssociationInfo(".TryExt_2");
                    FileAssociationInfo fai = new FileAssociationInfo(".arcPdf");
                    if (fai.Exists)
                    {
                        fai.Delete();
                    }

                    //if (!(fai.Exists))
                    {
                        //fai.Create("MyProgramName");
                        //fai.Create("TryExt_2_FileManager_ProgId");
                        fai.Create(sDocArc_ProgId);


                        //Specify MIME type (optional)
                        //fai.ContentType = "application/myfile";
                        fai.ContentType = "DocArchiver/arcPdf_File";



                        //Programs automatically displayed in open with list
                        //fai.OpenWithList = new string[] { "notepad.exe", "wordpad.exe", "someotherapp.exe" };
                        //fai.OpenWithList = new string[] { "TryExt_FileManager.exe" };
                        fai.OpenWithList = new string[] { "DocMarkReader.exe" };
                    }
                }



                {
                    //FileAssociationInfo fai = new FileAssociationInfo(".bob");
                    //FileAssociationInfo fai = new FileAssociationInfo(".TryExt_2");
                    FileAssociationInfo fai = new FileAssociationInfo(".corPdf");
                    if (fai.Exists)
                    {
                        fai.Delete();
                    }

                    //if (!(fai.Exists))
                    {
                        //fai.Create("MyProgramName");
                        //fai.Create("TryExt_2_FileManager_ProgId");
                        //fai.Create(sDocArc_ProgId);
                        fai.Create("AcroExch.Document");


                        //Specify MIME type (optional)
                        //fai.ContentType = "application/myfile";
                        //fai.ContentType = "DocArchiver/arcPdf_File";
                        fai.ContentType = "application/pdf";



                        //Programs automatically displayed in open with list
                        //fai.OpenWithList = new string[] { "notepad.exe", "wordpad.exe", "someotherapp.exe" };
                        //fai.OpenWithList = new string[] { "TryExt_FileManager.exe" };
                        fai.OpenWithList = new string[] { "AcroRd32.exe" };
                    }
                }



                //////////////////////////////////////////////////

                {
                    //ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
                    ProgramAssociationInfo pai = new ProgramAssociationInfo(sDocArc_ProgId);

                    if (pai.Exists)
                    {
                        pai.Delete();
                    }


                    //if (!(pai.Exists))
                    {
                        pai.Create
                        (
                            //Description of program/file type
                            "DocArchiver's File Type",

                            new ProgramVerb
                            (
                                //Verb name
                                "Open",
                                //Path and arguments to use
                                //@"C:\SomePath\MyApp.exe %1"
                                @"E:\HthmWork\Projects\VS-2010\DocArchiver\DocMarkReader\bin\Debug\DocMarkReader.exe %1"
                            )
                        );

                        //optional
                        //pai.DefaultIcon = new ProgramIcon(@"C:\SomePath\SomeIcon.ico");
                        pai.DefaultIcon = new ProgramIcon(
                            //pai.Se.setde DefaultIcon = new ProgramIcon(
                            @"E:\HthmWork\Projects\VS-2010\DocArchiver\DocMarkReader\Icon1.ico");
                    }
                }



                MessageBox.Show("Success !");
            }
            catch
            {
                MessageBox.Show("Error!.. Probabliy security problem.\r\n\r\n" +
                                "Try to right click the application, and run it as administrator");
            }
        }