/// <summary> /// /// </summary> void InitFileAssociations() { FileAssociationInfo fai = new FileAssociationInfo(".mvcmap"); if (!fai.Exists) { fai.Create("RatCow.MvcFramework.MVCMAP"); fai.ContentType = "application/mvcmap-xml"; //Programs automatically displayed in open with list fai.OpenWithList = new string[] { "mvcmaptool.exe", "notepad.exe", "wordpad.exe", "sublimeedit2.exe" }; } ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); if (!pai.Exists) { pai.Create ( //Description of program/file type "RatCow Soft MvcFramework MVCMAP editor", new ProgramVerb( "Open", //Verb name String.Format("{0} %1", Application.ExecutablePath) //Path and arguments to use ) ); } }
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); } }
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");*/ }
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { //run with admin - set file assoc FileAssociationInfo fai = new FileAssociationInfo(".zpaq"); if (!fai.Exists) { fai.Create("zpaq_gui"); //fai.ContentType = "application/zpaq"; //MIME type (is optional) fai.OpenWithList = new string[] { "zpaq-gui.exe" }; } ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); if (!pai.Exists) { pai.Create ( //Description of program/file type ".zpaq compression", new ProgramVerb ( //Verb name "Open", //Path and arguments to use System.Reflection.Assembly.GetEntryAssembly().Location ) ); //optional pai.DefaultIcon = new ProgramIcon(@"C:\SomePath\SomeIcon.ico"); } }
private void tabControl_SelectedIndexChanged(object sender, EventArgs e) { if (this.tabControl.SelectedTab == this.tabPageAssociations) { ProgramAssociationInfo programAssociationInfo = new ProgramAssociationInfo("TRE Explorer"); if (!programAssociationInfo.Exists) { programAssociationInfo.Create(new ProgramVerb("Open", "\"" + Application.ExecutablePath + "\" \"%1\"")); programAssociationInfo.DefaultIcon = new ProgramIcon(Application.ExecutablePath, 0); } else { if (programAssociationInfo.Verbs.Length > 0) { for (Int32 counter = 0; counter < programAssociationInfo.Verbs.Length; counter++) { if ((programAssociationInfo.Verbs[counter].Name == "Open") && (programAssociationInfo.Verbs[counter].Command != "\"" + Application.ExecutablePath + "\" \"%1\"")) { programAssociationInfo.RemoveVerb(programAssociationInfo.Verbs[counter]); programAssociationInfo.AddVerb(new ProgramVerb("Open", "\"" + Application.ExecutablePath + "\" \"%1\"")); break; } } } else { programAssociationInfo.AddVerb(new ProgramVerb("Open", "\"" + Application.ExecutablePath + "\" \"%1\"")); } if (programAssociationInfo.DefaultIcon.Path != Application.ExecutablePath) { programAssociationInfo.DefaultIcon = new ProgramIcon(Application.ExecutablePath, 0); } } for (Int32 counter = 0; counter < this.checkedListBoxFileTypes.Items.Count; counter++) { FileAssociationInfo fileAssociationInfo = new FileAssociationInfo("." + this.checkedListBoxFileTypes.Items[counter].ToString().ToLower()); if (fileAssociationInfo.Exists) { if (fileAssociationInfo.ProgID == "TRE Explorer") { this.checkedListBoxFileTypes.SetItemChecked(counter, true); } else { this.checkedListBoxFileTypes.SetItemChecked(counter, false); } } else { this.checkedListBoxFileTypes.SetItemChecked(counter, false); } } } }
private static void AssociateMainData(string ProgID, string Description, EditFlags flags, IconIndex IconIndex) { ProgramAssociationInfo a = new ProgramAssociationInfo(ProgID); if (!a.Exists) { a.Create(); } Registry.LocalMachine.OpenSubKey("SOFTWARE", true).OpenSubKey("Classes", true).OpenSubKey(ProgID, true).CreateSubKey("DefaultIcon", RegistryKeyPermissionCheck.ReadWriteSubTree).SetValue("", PathToIcons + ',' + (int)IconIndex); a.Description = Description; a.EditFlags = flags; }
public void Create(string exeName, string exePath, string iconPath) { if (!_fileAssociationInfo.Exists) { _fileAssociationInfo.Create(ProgramId); _fileAssociationInfo.ContentType = "application/x-qif"; _fileAssociationInfo.OpenWithList = new string[] { exeName }; } if (!_programAssociationInfo.Exists) { _programAssociationInfo.Create("Quicken Interexchange Format", new ProgramVerb("Open", $"\"{exePath}\" \"%1\"")); _programAssociationInfo.DefaultIcon = new ProgramIcon(iconPath); } }
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); }
//Prompt for new program id and create it if it does not exist. private void newProgramAssociationButton_Click(object sender, EventArgs e) { NewProgramAssociationDialog dialog = new NewProgramAssociationDialog(); if (dialog.ShowDialog() == DialogResult.OK) { ProgramAssociationInfo pai = new ProgramAssociationInfo(dialog.ProgramID); if (pai.Exists) { MessageBox.Show("Specified program already exists and will not be added"); } else { pai.Create(); } refreshExtensionsButton_Click(null, null); } }
void InitFileAssociations() { FileAssociationInfo fai = new FileAssociationInfo(".meo"); if (!fai.Exists) { fai.Create("MattsExperimentalOutliner"); //Specify MIME type (optional) fai.ContentType = "application/outliner-data"; //Programs automatically displayed in open with list fai.OpenWithList = new string[] { "outliner.exe", "notepad.exe", "someotherapp.exe" }; } ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); if (!pai.Exists) { pai.Create ( //Description of program/file type "Matt's Experimental Outliner", new ProgramVerb( //Verb name "Open", //Path and arguments to use String.Format("{0} %1", Application.ExecutablePath) ) ); //optional //pai.DefaultIcon = new ProgramIcon(@"C:\SomePath\SomeIcon.ico"); } }
static void Main(string[] args) { Console.WriteLine(""); FileAssociationInfo fai = new FileAssociationInfo(".ice"); fai.Create("IceFile"); //Specify MIME type (optional) fai.ContentType = "code/icefile"; //Programs automatically displayed in open with list fai.OpenWithList = new string[] { "notepad.exe", "wordpad.exe", "atom.exe", "Notepad++.exe" }; ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); pai.Create ( //Description of program/file type "Ice File", new ProgramVerb ( //Verb name "Open", //Path and arguments to use Environment.GetEnvironmentVariable("windir") + "\\system32\\notepad.exe %1%" ) ); Process regeditProcess = Process.Start("regedit.exe", "/s filetype.reg"); regeditProcess.WaitForExit(); //pai.DefaultIcon = new ProgramIcon(@"C:\Program Files\Ice\iceicon.ico"); }
static void Main(string[] args) { FileAssociationInfo fai = new FileAssociationInfo(".ice"); if (!fai.Exists) { fai.Create("IceFile"); //Specify MIME type (optional) fai.ContentType = "code/icefile"; //Programs automatically displayed in open with list fai.OpenWithList = new string[] { "notepad.exe", "wordpad.exe", "atom.exe", "Notepad++.exe" }; } ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); if (!pai.Exists) { pai.Create ( //Description of program/file type "Ice File", new ProgramVerb ( //Verb name "Open", //Path and arguments to use @"C:\Users\Ashley\AppData\Local\atom\app-1.12.5\atom.exe %1" ) ); pai.DefaultIcon = new ProgramIcon(@"C:\Program Files\Ice\iceicon.ico"); } }
public override void ValidateAlways(CommandLineArgument argument, ref string arg) { if (string.IsNullOrEmpty(arg)) { var exeName = Assembly.GetExecutingAssembly().Location; if (VpmUtils.PromptYayOrNay( "Do you want to register this vpm instance? (Open vpm:// or vpms:// url's and open .vpack files)", "It makes life so much easier.")) { try { VpmUtils.RegisterURIScheme("vpm"); VpmUtils.RegisterURIScheme("vpms"); var fai = new FileAssociationInfo(".vpack"); if (!fai.Exists) { fai.Create("vpm"); fai.ContentType = "text/vpack"; } var pai = new ProgramAssociationInfo(fai.ProgID); var progverb = new ProgramVerb("Open", exeName + " %1"); if (pai.Exists) { foreach (var pv in pai.Verbs) { pai.RemoveVerb(pv); } pai.AddVerb(progverb); } else { pai.Create("VVVV Package Definition", progverb); pai.DefaultIcon = new ProgramIcon(exeName); } Console.WriteLine("Registered protocols successfully"); } catch (Exception) { if (VpmUtils.PromptYayOrNay("Can't write to registry. Retry as Admin?")) { try { var startInfo = new ProcessStartInfo(exeName) { Arguments = "-RegisterVpmUri", Verb = "runas" }; Process.Start(startInfo); } catch (Exception) { Console.WriteLine("Error occured while trying to run elevated process."); Thread.Sleep(5000); } Environment.Exit(0); } } } Console.WriteLine("Alright, enjoy!"); Thread.Sleep(5000); Environment.Exit(0); } arg = arg.Trim('"'); if (arg.StartsWith("vpm://", true, CultureInfo.InvariantCulture)) { if (arg.EndsWith(".vpack", true, CultureInfo.InvariantCulture)) { return; } } if (arg.StartsWith("vpms://", true, CultureInfo.InvariantCulture)) { if (arg.EndsWith(".vpack", true, CultureInfo.InvariantCulture)) { return; } } if (File.Exists(arg)) { if (arg.EndsWith(".vpack", true, CultureInfo.InvariantCulture)) { arg = Path.GetFullPath(arg); return; } } throw new ValidationArgException("File not found or file is not .vpack"); }
private void MergeSqlProjectFileChanges( ) { // Actually not changed if (_options.SqlProjectFileAssociated == chkAssociateSqlProjectFiles.Checked) { return; } _options.SqlProjectFileAssociated = chkAssociateSqlProjectFiles.Checked; FileAssociationInfo fa = null; ProgramAssociationInfo pa = null; if (chkAssociateSqlProjectFiles.Checked) { fa = new FileAssociationInfo(".sqlprj"); // File association info exists. We have to backup current settings if (fa.Exists) { //Backup open with list _options.SqlProjectOpenWithBackup.AddRange(fa.OpenWithList); //Backup verbs pa = new ProgramAssociationInfo(fa.ProgID); if (pa.Exists) { _options.SqlProjectVerbsBackup.AddRange(pa.Verbs); _options.SqlProjectFileProgramIDBackup = pa.ProgID; } } // File association info does not exists. We will create else { fa.Create("PragmaSQL Project File"); pa = new ProgramAssociationInfo(fa.ProgID); } fa.OpenWithList = new string[1] { "PragmaSQL.exe" }; pa = new ProgramAssociationInfo(fa.ProgID); if (!pa.Exists) { pa.Create(); } if (pa != null && pa.Exists) { ProgramVerb verb = new ProgramVerb("open", SystemFileAssociationOptions.PragmaSQLOpenCommand); pa.Verbs = new ProgramVerb[1] { verb }; } } else { // Rollback to backup fa = new FileAssociationInfo(".sqlprj"); if (fa.Exists) { fa.OpenWithList = _options.SqlProjectOpenWithBackup.ToArray(); _options.SqlProjectOpenWithBackup.Clear(); pa = new ProgramAssociationInfo(fa.ProgID); if (pa.Exists) { pa.Delete(); if (!String.IsNullOrEmpty(_options.SqlProjectFileProgramIDBackup)) { pa = new ProgramAssociationInfo(_options.SqlProjectFileProgramIDBackup); if (!pa.Exists) { pa.Create(); } pa.Verbs = _options.SqlProjectVerbsBackup.ToArray(); } _options.SqlProjectVerbsBackup.Clear(); } } } }
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; } }
private void Form1_Load(object sender, EventArgs e) { if (launchedtroughextension == true) { } else { FileAssociationInfo fai = new FileAssociationInfo(".zortosunzip"); if (!fai.Exists) { fai.Create("ZortosUnzipper"); //Specify MIME type (optional) fai.ContentType = "application/zip"; //Programs automatically displayed in open with list fai.OpenWithList = new string[] { "explorer.exe" }; } ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); if (!pai.Exists) { pai.Create ( //Description of program/file type "ZortosExplorer Automaticly Unzips da file", new ProgramVerb ( //Verb name "Open", //Path and arguments to use Path.GetTempPath() + "ZortosExplorer.exe" + " " + Application.ExecutablePath ) ); //optional pai.DefaultIcon = new ProgramIcon(Path.GetTempPath() + "ZortosExplorer.exe"); } } string[] arguments = Environment.GetCommandLineArgs(); string argumentinstring = string.Join(", ", arguments); if (argumentinstring.EndsWith(@".zortosunzip")) { MessageBox.Show("Unzipping Please Wait"); using (var archive = ZipArchive.Open(argumentinstring.Substring(argumentinstring.IndexOf(',') + 1))) { foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { entry.WriteToDirectory(Path.GetTempPath() + @"ZortosUnzipper", new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); } } //ZipFile.ExtractToDirectory(argumentinstring.Substring(argumentinstring.IndexOf(',') + 1), Path.GetTempPath() + @"ZortosUnzipper"); MessageBox.Show("Done File Extracted inside" + "\n" + Path.GetTempPath() + @"ZortosUnzipper"); Dispose(); Environment.Exit(0); } if (argumentinstring.EndsWith(@".zip")) { MessageBox.Show("Unzipping Please Wait"); using (var archive = ZipArchive.Open(argumentinstring.Substring(argumentinstring.IndexOf(',') + 1))) { foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { entry.WriteToDirectory(Path.GetTempPath() + @"ZortosUnzipper", new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); } } //ZipFile.ExtractToDirectory(argumentinstring.Substring(argumentinstring.IndexOf(',') + 1), Path.GetTempPath() + @"ZortosUnzipper"); MessageBox.Show("Done File Extracted inside" + "\n" + Path.GetTempPath() + @"ZortosUnzipper"); Dispose(); Environment.Exit(0); } if (argumentinstring.EndsWith(".7z")) { MessageBox.Show("Unzipping Please Wait"); using (var archive = SevenZipArchive.Open(argumentinstring.Substring(argumentinstring.IndexOf(',') + 1))) { foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { entry.WriteToDirectory(Path.GetTempPath() + @"ZortosUnzipper", new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); } } MessageBox.Show("Done File Extracted inside" + "\n" + Path.GetTempPath() + @"ZortosUnzipper"); Dispose(); Environment.Exit(0); } if (argumentinstring.EndsWith(".rar")) { MessageBox.Show("Unzipping Please Wait"); using (var archive = RarArchive.Open(argumentinstring.Substring(argumentinstring.IndexOf(',') + 1))) { foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) { entry.WriteToDirectory(Path.GetTempPath() + @"ZortosUnzipper", new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); } } MessageBox.Show("Done File Extracted inside:" + "\n" + Path.GetTempPath() + @"ZortosUnzipper"); Dispose(); Environment.Exit(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 !"); }
void associationTypeAndIcon() { FileAssociationInfo fai = new FileAssociationInfo(".autoc"); FileAssociationInfo fai1 = new FileAssociationInfo(".tarif"); FileAssociationInfo fai2 = new FileAssociationInfo(".acc"); //if (!fai.Exists && Services.etat==0) //{ fai.Create("AutoConsultation"); //Specify MIME type (optional) fai.ContentType = "application/AutoConsultation-app"; //Programs automatically displayed in open with list fai.OpenWithList = new string[] { "autoc.exe" }; //} //if (!fai1.Exists && Services.etat == 0) //{ fai1.Create("Tarif-AutoConsultation"); //Specify MIME type (optional) fai1.ContentType = "application/AutoConsultation-app"; //Programs automatically displayed in open with list fai1.OpenWithList = new string[] { "autoc.exe" }; //} //if (!fai2.Exists && Services.etat == 0) //{ fai2.Create("Acc-AutoConsultation"); //Specify MIME type (optional) fai2.ContentType = "application/AutoConsultation-app"; //Programs automatically displayed in open with list fai2.OpenWithList = new string[] { "autoc.exe" }; //} ///////////////////////////////////////////////////// ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); ProgramAssociationInfo pai1 = new ProgramAssociationInfo(fai1.ProgID); ProgramAssociationInfo pai2 = new ProgramAssociationInfo(fai2.ProgID); //if (!pai.Exists && Services.etat == 0) //{ string StartupPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Remove(0, 6); string c = Path.Combine(StartupPath, "autoc.exe"); string c1 = Path.Combine(StartupPath, "fileico.ico"); pai.Create ( //Description of program/file type "fichier d'Auto Consultation ", new ProgramVerb ( //Verb name "autoc", //Path and arguments to use c + " %0" ) ); //optional pai.DefaultIcon = new ProgramIcon(c1); //} //if (!pai1.Exists && Services.etat == 0) //{ StartupPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Remove(0, 6); c = Path.Combine(StartupPath, "autoc.exe"); c1 = Path.Combine(StartupPath, "tarif.ico"); pai1.Create ( //Description of program/file type "ficher Tarif d'Auto Consultation ", new ProgramVerb ( //Verb name "tarif", //Path and arguments to use c + " %0" ) ); //optional pai1.DefaultIcon = new ProgramIcon(c1); //} //if (!pai2.Exists && Services.etat == 0) //{ StartupPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Remove(0, 6); c = Path.Combine(StartupPath, "autoc.exe"); c1 = Path.Combine(StartupPath, "acc.ico"); pai2.Create ( //Description of program/file type "ficher accessoire d'Auto Consultation ", new ProgramVerb ( //Verb name "acc", //Path and arguments to use c + " %0" ) ); //optional pai2.DefaultIcon = new ProgramIcon(c1); //} }
///// <summary> ///// Sets the language ///// </summary> //public void SetLanguage() //{ // string languageFilePath = Path.Combine(Program.LanguagesDirectory, // String.Format("{0}.json", Settings.Default.Language.Name)); // if (File.Exists(languageFilePath)) // _lp = Serializer.Deserialize<LocalizationProperties>(File.ReadAllText(languageFilePath)); // else // { // File.WriteAllBytes(Path.Combine(Program.LanguagesDirectory, "en.json"), Resources.en); // Settings.Default.Language = new CultureInfo("en"); // Settings.Default.Save(); // Settings.Default.Reload(); // _lp = Serializer.Deserialize<LocalizationProperties>(File.ReadAllText(languageFilePath)); // } // Text = _lp.ProductTitle; // headerLabel.Text = _lp.ProductTitle; // infoLabel.Text = _lp.MainDialogInfoText; // sectionsListView.Groups[0].Header = _lp.MainDialogProjectsGroupText; // sectionsListView.Groups[1].Header = _lp.MainDialogInformationGroupText; // sectionsListView.Groups[2].Header = _lp.MainDialogPreferencesGroupText; // sectionsListView.Items[0].Text = _lp.MainDialogNewProjectText; // sectionsListView.Items[1].Text = _lp.MainDialogOpenProjectText; // sectionsListView.Items[4].Text = _lp.MainDialogFeedbackText; // sectionsListView.Items[5].Text = _lp.MainDialogPreferencesText; // sectionsListView.Items[6].Text = _lp.MainDialogInformationText; //} private void MainDialog_Load(object sender, EventArgs e) { if (Environment.OSVersion.Version.Major < 6) { var dr = MessageBox.Show("Your operating system is not supported.", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); if (dr == DialogResult.OK) { Application.Exit(); } } try { var fai = new FileAssociationInfo(".nupdproj"); if (!fai.Exists) { fai.Create("nUpdate Administration"); var pai = new ProgramAssociationInfo(fai.ProgId); if (!pai.Exists) { pai.Create("nUpdate Administration Project File", new ProgramVerb("Open", $"\"{Application.ExecutablePath} %1\"")); pai.DefaultIcon = new ProgramIcon(Application.ExecutablePath); } } } catch (UnauthorizedAccessException) { Popup.ShowPopup(this, SystemIcons.Warning, "Missing rights.", "The registry entry for the extension (.nupdproj) couldn't be created. Without that file extension nUpdate Administration won't work correctly. Please make sure to start the administration with admin privileges the first time.", PopupButtons.Ok); } if (string.IsNullOrWhiteSpace(Settings.Default.ProgramPath)) { Settings.Default.ProgramPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "nUpdate Administration"); } Program.LanguagesDirectory = Path.Combine(Program.Path, "Localization"); if (!Directory.Exists(Program.LanguagesDirectory)) { Directory.CreateDirectory(Program.LanguagesDirectory); // Create the directory // Save the language content var lang = new LocalizationProperties(); var content = Serializer.Serialize(lang); File.WriteAllText(Path.Combine(Program.LanguagesDirectory, "en.json"), content); } if (!File.Exists(Program.ProjectsConfigFilePath)) { using (File.Create(Program.ProjectsConfigFilePath)) { } } if (!File.Exists(Program.StatisticServersFilePath)) { using (File.Create(Program.StatisticServersFilePath)) { } } var projectsPath = Path.Combine(Program.Path, "Projects"); if (!Directory.Exists(projectsPath)) { Directory.CreateDirectory(projectsPath); } //SetLanguage(); sectionsListView.DoubleBuffer(); Text = string.Format(Text, Program.VersionString); headerLabel.Text = string.Format(Text, Program.VersionString); }
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"); } }
public FileAssociations() { InitializeComponent(); this.chkAlwaysCheckFileAssociations.IsChecked = Properties.Settings.Default.AlwaysCheckFileAssociations; RegistryHelper.UseCurrentUser = true; //Ensure there is Program Association Info for us in the Registry ProgramAssociationInfo rdfEditorInfo = new ProgramAssociationInfo(RegistryProgramID); if (!rdfEditorInfo.Exists) { rdfEditorInfo.Create(); } bool hasOpenVerb = false; foreach (ProgramVerb verb in rdfEditorInfo.Verbs) { if (verb.Name.Equals("open")) { if (verb.Command.StartsWith(System.IO.Path.GetFullPath("rdfEditor.exe"))) { hasOpenVerb = true; } else { rdfEditorInfo.RemoveVerb("open"); } } } if (!hasOpenVerb) { rdfEditorInfo.AddVerb(new ProgramVerb("open", System.IO.Path.GetFullPath("rdfEditor.exe") + " \"%1\"")); } //See which extensions are currently associated to us foreach (FileAssociationInfo info in _associations) { if (!info.Exists) { //If no association exists then we'll aim to create it this.SetAssociationsChecked(info.Extension); } else { //Check if the File Associations Program ID is equal to ours if (info.ProgID.Equals(RegistryProgramID)) { //Prog ID is equal to ours to we are associated with this extension this._currentAssociations.Add(info.Extension); this.SetAssociationsChecked(info.Extension); } else if (info.ProgID.Equals(String.Empty)) { //No Prog ID specified so we'll aim to create it this.SetAssociationsChecked(info.Extension); } else { ProgramAssociationInfo progInfo = new ProgramAssociationInfo(info.ProgID); if (!progInfo.Exists) { //No program association exists so we'll aim to create it this.SetAssociationsChecked(info.Extension); } else { //Associated with some other program currently bool hasExistingOpen = false; foreach (ProgramVerb verb in progInfo.Verbs) { if (verb.Name.Equals("open")) { hasExistingOpen = true; } } //No Open Verb so we'll try to associated with ourselves if (!hasExistingOpen) { this.SetAssociationsChecked(info.Extension); } } } } } }
///// <summary> ///// Sets the language ///// </summary> //public void SetLanguage() //{ // string languageFilePath = Path.Combine(Program.LanguagesDirectory, // String.Format("{0}.json", Settings.Default.Language.Name)); // if (File.Exists(languageFilePath)) // _lp = Serializer.Deserialize<LocalizationProperties>(File.ReadAllText(languageFilePath)); // else // { // File.WriteAllBytes(Path.Combine(Program.LanguagesDirectory, "en.json"), Resources.en); // Settings.Default.Language = new CultureInfo("en"); // Settings.Default.Save(); // Settings.Default.Reload(); // _lp = Serializer.Deserialize<LocalizationProperties>(File.ReadAllText(languageFilePath)); // } // Text = _lp.ProductTitle; // headerLabel.Text = _lp.ProductTitle; // infoLabel.Text = _lp.MainDialogInfoText; // sectionsListView.Groups[0].Header = _lp.MainDialogProjectsGroupText; // sectionsListView.Groups[1].Header = _lp.MainDialogInformationGroupText; // sectionsListView.Groups[2].Header = _lp.MainDialogPreferencesGroupText; // sectionsListView.Items[0].Text = _lp.MainDialogNewProjectText; // sectionsListView.Items[1].Text = _lp.MainDialogOpenProjectText; // sectionsListView.Items[4].Text = _lp.MainDialogFeedbackText; // sectionsListView.Items[5].Text = _lp.MainDialogPreferencesText; // sectionsListView.Items[6].Text = _lp.MainDialogInformationText; //} private void MainDialog_Load(object sender, EventArgs e) { if (Environment.OSVersion.Version.Major < 6) { var dr = MessageBox.Show("Your operating system is not supported.", String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); if (dr == DialogResult.OK) { Application.Exit(); } } try { var fai = new FileAssociationInfo(".nupdproj"); if (!fai.Exists) { fai.Create("nUpdate Administration"); var pai = new ProgramAssociationInfo(fai.ProgId); if (!pai.Exists) { pai.Create("nUpdate Administration Project File", new ProgramVerb("Open", String.Format("\"{0} %1\"", Application.ExecutablePath))); pai.DefaultIcon = new ProgramIcon(Application.ExecutablePath); } } } catch (UnauthorizedAccessException) { Popup.ShowPopup(this, SystemIcons.Error, "Missing rights.", "You don't own the rights to create the extension's registry entry.", PopupButtons.Ok); } Program.LanguagesDirectory = Path.Combine(Program.Path, "Localization"); if (!Directory.Exists(Program.LanguagesDirectory)) { Directory.CreateDirectory(Program.LanguagesDirectory); // Create the directory // Save the language content var lang = new LocalizationProperties(); var content = Serializer.Serialize(lang); File.WriteAllText(Path.Combine(Program.LanguagesDirectory, "en.json"), content); } if (!File.Exists(Program.ProjectsConfigFilePath)) { using (File.Create(Program.ProjectsConfigFilePath)) { } } if (!File.Exists(Program.StatisticServersFilePath)) { using (File.Create(Program.StatisticServersFilePath)) { } } var projectsPath = Path.Combine(Program.Path, "Projects"); if (!Directory.Exists(projectsPath)) { Directory.CreateDirectory(projectsPath); } //SetLanguage(); sectionsListView.DoubleBuffer(); }