Beispiel #1
0
        /// <summary>
        /// Creates actual extension association key in registry for the specified extension and supplied attributes.
        /// </summary>
        /// <param name="progId">Name of expected handling program.</param>
        /// <param name="perceivedType"><see cref="PerceivedTypes"/>PerceivedType of file type.</param>
        /// <param name="contentType">MIME type of file type.</param>
        /// <param name="openwithList"></param>
        /// <returns>FileAssociationInfo instance referring to specified extension.</returns>
        public FileAssociationInfo Create(string progId, PerceivedTypes perceivedType, string contentType, string[] openwithList)
        {
            FileAssociationInfo fai = new FileAssociationInfo(extension);

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

            fai.Create();
            fai.ProgID = progId;

            if (perceivedType != PerceivedTypes.None)
            {
                fai.PerceivedType = perceivedType;
            }

            if (contentType != string.Empty)
            {
                fai.ContentType = contentType;
            }

            if (openwithList != null)
            {
                fai.OpenWithList = openwithList;
            }

            return(fai);
        }
Beispiel #2
0
        /// <summary>
        /// Associates an already existing program id with a list of extensions.
        /// </summary>
        /// <param name="progId">The program id to associate extensions with.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        public void Associate(string progId, params string[] extensions)
        {
            foreach (string s in extensions)
            {
                FileAssociationInfo fai = new FileAssociationInfo(s);

                if (!fai.Exists)
                {
                    fai.Create(progId);
                }

                fai.ProgID = progId;
            }
        }
Beispiel #3
0
 private static void AssociateTorrents(string installationPath)
 {
     var path = Path.Combine(installationPath, "Patchy.exe");
     var torrent = new FileAssociationInfo(".torrent");
     torrent.Create("Patchy");
     torrent.ContentType = "application/x-bittorrent";
     torrent.OpenWithList = new[] { "patchy.exe" };
     var program = new ProgramAssociationInfo(torrent.ProgID);
     if (!program.Exists)
     {
         program.Create("Patchy Torrent File", new ProgramVerb("Open", string.Format(
             "\"{0}\" \"%1\"", path)));
         program.DefaultIcon = new ProgramIcon(path);
     }
 }
Beispiel #4
0
 public static void Run()
 {
     FileAssociationInfo associate = new FileAssociationInfo(".plist");
     if (!associate.Exists)
     {
         associate.Create();
     }
     associate.ContentType = "Application/PList";
     associate.ProgID = "ProperityList";
     ////if (associate.OpenWithList == null)
     //{
     //    associate.OpenWithList = new string[]{
     //        args
     //    };
     //}
     //else if(!associate.OpenWithList.Contains("args"))
     //{
     //    List<string> list = new List<string>();
     //    list.Add(args);
     //    list.AddRange(associate.OpenWithList);
     //    associate.OpenWithList = list.ToArray();
     //}
     string args = Path.GetFullPath(Path.Combine(Application.StartupPath, "IPATools.PlistEditor.exe")) + " \"%1\"";
     string ico = Path.Combine(Application.StartupPath, "file.ico");
     ProgramVerb open = new ProgramVerb("Open", args);
     ProgramAssociationInfo pai = new ProgramAssociationInfo(associate.ProgID);
     if (!pai.Exists)
     {
         pai.Create("ProperityList", open);
     }
     else
     {
         for (int i = 0; i < pai.Verbs.Length; i++)
         {
             if (pai.Verbs[i].Name.Equals("open", StringComparison.OrdinalIgnoreCase))
             {
                 pai.RemoveVerb(pai.Verbs[i]);
                 pai.AddVerb(open);
                 break;
             }
         }
     }
     pai.DefaultIcon = new ProgramIcon(ico);
 }
Beispiel #5
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;
        }
Beispiel #6
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %1"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, params string[] extensions )
        {
            foreach (string s in extensions)
             {
            FileAssociationInfo fai = new FileAssociationInfo(s);

            if (!fai.Exists)
               fai.Create(progId);

            fai.ProgID = progId;
             }

             ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

             if (!pai.Exists)
            pai.Create();

             pai.AddVerb(new ProgramVerb("open", executablePath));
        }
Beispiel #7
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %1"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, params string[] extensions)
        {
            foreach (string s in extensions)
            {
                FileAssociationInfo fai = new FileAssociationInfo(s);

                if (!fai.Exists)
                {
                    fai.Create(progId);
                }

                fai.ProgID = progId;
            }

            ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

            if (!pai.Exists)
            {
                pai.Create();
            }

            pai.AddVerb(new ProgramVerb("open", executablePath));
        }
Beispiel #8
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %L"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, string extension, ProgramIcon icon = null)
        {
            FileAssociationInfo fai = new FileAssociationInfo(extension);

            if (!fai.Exists)
            {
                fai.Create(progId);
            }

            fai.ProgID = progId;

            ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

            if (!pai.Exists)
            {
                pai.Create();
            }

            pai.AddVerb(new ProgramVerb("open", executablePath));
            if (icon != null)
            {
                pai.DefaultIcon = icon;
            }
        }
Beispiel #9
0
      /// <summary>
      /// Creates actual extension association key in registry for the specified extension and supplied attributes.
      /// </summary>
      /// <param name="progId">Name of expected handling program.</param>
      /// <param name="perceivedType"><see cref="PerceivedTypes"/>PerceivedType of file type.</param>
      /// <param name="contentType">MIME type of file type.</param>
      /// <param name="openwithList"></param>
      /// <returns>FileAssociationInfo instance referring to specified extension.</returns>
      public FileAssociationInfo Create(string progId, PerceivedTypes perceivedType, string contentType, string[] openwithList)
      {
         FileAssociationInfo fai = new FileAssociationInfo(extension);

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

         fai.Create();
         fai.ProgID = progId;

         if (perceivedType != PerceivedTypes.None)
            fai.PerceivedType = perceivedType;

         if (contentType != string.Empty)
            fai.ContentType = contentType;

         if (openwithList != null)
            fai.OpenWithList = openwithList;

         return fai;
      }
 private void torrentAssociationCheckBoxChecked(object sender, RoutedEventArgs e)
 {
     var torrent = new FileAssociationInfo(".torrent");
     if (torrentAssociationCheckBox.IsChecked.Value)
     {
         torrent.Create("Patchy");
         torrent.ContentType = "application/x-bittorrent";
         torrent.OpenWithList = new[] { "patchy.exe" };
         var program = new ProgramAssociationInfo(torrent.ProgID);
         if (!program.Exists)
         {
             program.Create("Patchy Torrent File", new ProgramVerb("Open", string.Format(
                 "\"{0}\" \"%1\"", Path.Combine(Assembly.GetEntryAssembly().Location))));
             program.DefaultIcon = new ProgramIcon(Assembly.GetEntryAssembly().Location);
         }
     }
     else
         torrent.Delete();
 }
Beispiel #11
0
        private static void createWYZFileAssociation()
        {
            FileAssociationInfo fai = new FileAssociationInfo(".wyz");
            if (!fai.Exists)
            {
                fai.Create("WYZTracker");
                fai.ContentType = "application/wyz-song-file";
                fai.OpenWithList = new string[] {
                        "WYZTracker.exe"
                    };
            }

            ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID);
            if (!pai.Exists ||
                pai.Verbs.Length == 0 ||
                !pai.Verbs[0].Command.ToLower().Contains(Application.ExecutablePath.ToLower()))
            {
                pai.Create(
                    WYZTracker.Properties.Resources.WYZFileDesc,
                    new ProgramVerb(
                        WYZTracker.Properties.Resources.OpenVerb,
                        string.Format("\"{0}\" \"%1\"", Application.ExecutablePath)
                        )
                    );
                pai.DefaultIcon = new ProgramIcon(Application.ExecutablePath);
            }
        }
      //Prompt for new extension and create it if it does not exist
      private void addExtension_Click(object sender, EventArgs e)
      {
         NewExtensionDialog dialog = new NewExtensionDialog();

         if (dialog.ShowDialog() == DialogResult.OK)
         {
            FileAssociationInfo fai = new FileAssociationInfo(dialog.Extension);

            if (fai.Exists)
            {
               MessageBox.Show("Specified extension already exists and will not be added");
            }
            else
            {
               fai.Create();
            }
            
            refreshExtensionsButton_Click(null, null);
         }

      }
Beispiel #13
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;
            }
        }
Beispiel #14
0
		/// <summary>
		/// Associates an already existing program id with a list of extensions.
		/// </summary>
		/// <param name="progId">The program id to associate extensions with.</param>
		/// <param name="extensions">String array of extensions to associate with program id.</param>
		public static void Associate(string progId, params string[] extensions)
		{
			foreach (string s in extensions)
			{
				FileAssociationInfo fai = new FileAssociationInfo(s);

				if (!fai.Exists)
					fai.Create(progId);

				fai.ProgID = progId;
			}
		}
Beispiel #15
0
        /// <summary>
        /// Associates a single executable with a list of extensions.
        /// </summary>
        /// <param name="progId">Name of program id</param>
        /// <param name="executablePath">Path to executable to start including arguments.</param>
        /// <param name="extensions">String array of extensions to associate with program id.</param>
        /// <example>progId = "MyTextFile"
        /// executablePath = "notepad.exe %L"
        /// extensions = ".txt", ".text"</example>
        public void Associate(string progId, string executablePath, string extension, ProgramIcon icon = null)
        {
            FileAssociationInfo fai = new FileAssociationInfo(extension);

              if (!fai.Exists)
              fai.Create(progId);

              fai.ProgID = progId;

              ProgramAssociationInfo pai = new ProgramAssociationInfo(progId);

              if (!pai.Exists)
              pai.Create();

              pai.AddVerb(new ProgramVerb("open", executablePath));
              if (icon != null)
            pai.DefaultIcon = icon;
        }
        private void associateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!UAC.IsAdmin())
            {
                if (!UAC.RestartElevated("assoc"))
                {
                    MessageBox.Show("Can't associate extension without admin rights!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
            else
            {

                DialogResult dRes = MessageBox.Show("Associate *.wad and *.spr files with this program?", "File(s) association",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dRes == System.Windows.Forms.DialogResult.Yes)
                {
                    FileAssociationInfo faiWad = new FileAssociationInfo(".wad");
                    FileAssociationInfo faiSpr = new FileAssociationInfo(".spr");
                    faiWad.Create(Application.ProductName);
                    faiSpr.Create(Application.ProductName);
                    faiWad.OpenWithList = new string[] { Application.ExecutablePath };
                    faiSpr.OpenWithList = new string[] { Application.ExecutablePath };

                    ProgramAssociationInfo paiWad = new ProgramAssociationInfo(faiWad.ProgID);
                    ProgramAssociationInfo paiSpr = new ProgramAssociationInfo(faiSpr.ProgID);
                    paiWad.Create(new ProgramVerb("Open", Application.ExecutablePath + " \"%1\""));
                    paiSpr.Create(new ProgramVerb("Open", Application.ExecutablePath + " \"%1\""));
                }
            }
        }