private void CreateSendToLink() { //http://stackoverflow.com/questions/234231/creating-application-shortcut-in-a-directory Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")); //Windows Script Host Shell Object dynamic shell = Activator.CreateInstance(t); try { string sendToPath = Environment.ExpandEnvironmentVariables(@"%AppData%\Microsoft\Windows\SendTo"); var lnk = shell.CreateShortcut(Path.Combine(sendToPath, "DoomLauncher.lnk")); try { lnk.TargetPath = Path.Combine(Directory.GetCurrentDirectory(), Util.GetExecutableNoPath()); lnk.IconLocation = string.Format(Path.Combine(Directory.GetCurrentDirectory(), "DoomLauncher.ico")); lnk.Save(); } finally { Marshal.FinalReleaseComObject(lnk); } } finally { Marshal.FinalReleaseComObject(shell); } }
private void AppConfiguration_GameFileViewTypeChanged(object sender, EventArgs e) { if (GameFileViewFactory.IsBaseViewTypeChange(GameFileViewFactory.DefaultType, AppConfiguration.GameFileViewType)) { // Write any settings the user may have changed before the application is killed HandleFormClosing(); Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Util.GetExecutableNoPath())); return; } GameFileViewFactory.UpdateDefaultType(AppConfiguration.GameFileViewType); GameFileTileManager.Instance.Init(GameFileViewFactory); }
private void CreateSendToLink() { //http://stackoverflow.com/questions/234231/creating-application-shortcut-in-a-directory Type t = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8")); //Windows Script Host Shell Object dynamic shell = Activator.CreateInstance(t); try { string sendToPath = Environment.ExpandEnvironmentVariables(@"%AppData%\Microsoft\Windows\SendTo"); var lnk = shell.CreateShortcut(Path.Combine(sendToPath, "DoomLauncher.lnk")); // This should always exist, but a user did report not having this folder on Windows 10... if (!Directory.Exists(sendToPath)) { Directory.CreateDirectory(sendToPath); } try { lnk.TargetPath = Path.Combine(Directory.GetCurrentDirectory(), Util.GetExecutableNoPath()); lnk.IconLocation = string.Format(Path.Combine(Directory.GetCurrentDirectory(), "DoomLauncher.ico")); lnk.Save(); } catch { // Do not crash just for failing to create SendTo link } finally { Marshal.FinalReleaseComObject(lnk); } } catch { // Do not crash just for failing to create SendTo link } finally { Marshal.FinalReleaseComObject(shell); } }
private bool ExecuteNonInstallUpdate() { List <RenameFile> renamedFiles = new List <RenameFile>(); try { using (ZipArchive za = ZipFile.OpenRead(m_zipArchive)) { var entries = za.Entries.Where(x => x.Name.Length > 0 && (x.FullName.StartsWith("DoomLauncher\\") || x.FullName.StartsWith("DoomLauncher/"))); if (!entries.Any()) { LastError = "Could not find DoomLauncher folder in archive."; return(false); } foreach (var entry in entries) { string file = Path.Combine(Directory.GetCurrentDirectory(), entry.Name); FileInfo fileInfo = new FileInfo(file); if (fileInfo.Exists) { renamedFiles.Add(new RenameFile(fileInfo.Name, RenameAppFile(fileInfo))); } entry.ExtractToFile(file); } } } catch (Exception ex) { SetLastErrorException(ex); RevertRenamedFiles(renamedFiles); return(false); } Process.Start(Path.Combine(m_executingDirectory, Util.GetExecutableNoPath())); return(true); }