Exemple #1
0
 private void ShortcutButton_Click(object sender, RoutedEventArgs e)
 {
     Task.Run(Sound);
     try
     {
         string pathToExe = Directory.GetCurrentDirectory() + "\\" + Process.GetCurrentProcess().ProcessName + ".exe";
         string desktop   = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
         WshInterop.CreateShortcut(desktop, null, pathToExe, null, null);
         ModernWpf.MessageBox.Show("Verknüpfung wurde erfolgreich erstellt!");
     }
     catch
     {
         ModernWpf.MessageBox.Show("Es gab einen Fehler beim erstellen; womöglich gibt es schon eine Verknüpfung.");
     }
 }
        private void CreateStartMenuShortcut()
        {
            string pathToExe        = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\SecretChat\\Versions\\" + currentVersion + "\\SecretChat.exe";
            string shortcutLocation = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs\\", "A Secret Chat" + ".lnk");

            if (!File.Exists(shortcutLocation))
            {
                WshInterop.CreateShortcut(shortcutLocation, null, pathToExe, null, null);
            }
            else if (GetShortcutTarget(shortcutLocation) != pathToExe)
            {
                File.Delete(shortcutLocation);
                WshInterop.CreateShortcut(shortcutLocation, null, pathToExe, null, null);
            }
        }
Exemple #3
0
 private void AutoStart_Click(object sender, RoutedEventArgs e)
 {
     Task.Run(Sound2);
     if (AutoStart.IsChecked == true)
     {
         System.IO.File.WriteAllText(path + "\\autostart.txt", "true");
         string startUpPath      = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
         string pathToExe        = Directory.GetCurrentDirectory() + "\\" + Process.GetCurrentProcess().ProcessName + ".exe";
         string shortcutLocation = System.IO.Path.Combine(startUpPath, "Secret Chat" + ".lnk");
         WshInterop.CreateShortcut(shortcutLocation, null, pathToExe, null, null);
     }
     else
     {
         System.IO.File.WriteAllText(path + "\\autostart.txt", "false");
         string startUpPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
         System.IO.File.Delete(startUpPath + "\\Secret Chat.lnk");
     }
 }