コード例 #1
0
        public void CreateShortcut(IWebBrowser browser)
        {
            var title = GetWebBrowserTitle(browser);

            foreach (var item in "\\/:*?\"<>|.")
            {
                title = title.Replace(item, '_');
            }

            var sfd = new Microsoft.Win32.SaveFileDialog()
            {
                FileName = title,
                Filter   = $"{LanguageManager.GetString("filter_shortcut")}|*.lnk",
            };

            if (sfd.ShowDialog() == true)
            {
                var path     = GetType().Assembly.Location;
                var arg      = browser.Address;
                var fileName = sfd.FileName;

                try
                {
                    WshShortcut shortcut = new WshShell().CreateShortcut(fileName);
                    shortcut.TargetPath = path;
                    shortcut.Arguments  = arg;
                    shortcut.Save();
                }
                catch (Exception e)
                {
                    JsAlertDialog.ShowDialog(e.Message);
                }
            }
        }
コード例 #2
0
        internal void CreateShortcut(string desktopPath)
        {
            IWshShortcut shortcut = new WshShell().CreateShortcut(Path.Combine(desktopPath, "Hotel Manager.lnk"));

            shortcut.Description      = "Hotel Manager";
            shortcut.WorkingDirectory = InstallPath;
            shortcut.TargetPath       = Path.Combine(InstallPath, "HotelManager.exe");
            shortcut.Save();
        }
コード例 #3
0
        public static void Create()
        {
            var shortcut = new WshShell()
                           .CreateShortcut(
                $"{Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)}\\KryBot.lnk")
                           as IWshShortcut;

            if (shortcut != null)
            {
                shortcut.TargetPath       = $"{Environment.CurrentDirectory}\\KryBot.exe";
                shortcut.WorkingDirectory = Environment.CurrentDirectory;
                shortcut.Save();
            }
        }
コード例 #4
0
        public static void CreateShortcut()
        {
            string link     = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Windows Live Messenger.lnk");
            var    shortcut = new WshShell().CreateShortcut(link) as IWshShortcut;

            shortcut.TargetPath       = Application.ExecutablePath;
            shortcut.WorkingDirectory = Application.StartupPath;
            shortcut.Arguments        = "-l";
            shortcut.WindowStyle      = (int)WshWindowStyle.WshNormalFocus;

            var cb = Properties.Settings.Default.CurrentBackup;
            var d  = MsnBackup.GetBackups().First(b => Path.GetFileName(b.Directory) == cb).Directory;

            shortcut.IconLocation = Path.GetFullPath(Path.Combine(d, "msnmsgr.exe")) + ",1";
            shortcut.Save();
        }
コード例 #5
0
        private void CreateShortcut(string path)
        {
            var shortcut =
                new WshShell().CreateShortcut(string.Format("{0}\\{1}.lnk",
                                                            Environment.GetFolderPath(Environment.SpecialFolder
                                                                                      .DesktopDirectory),
                                                            Path.GetFileNameWithoutExtension(path))) as IWshShortcut;

            if (shortcut == null)
            {
                MessageBox.Show("Create shortcut error", "LE", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            shortcut.TargetPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                               "LEProc.exe");
            shortcut.Arguments        = String.Format("-run \"{0}\"", path);
            shortcut.WorkingDirectory = Path.GetDirectoryName(path);
            shortcut.WindowStyle      = 1;
            shortcut.Description      = string.Format("Run {0} with Locale Emulator", Path.GetFileName(path));
            shortcut.IconLocation     = AssociationReader.GetAssociatedIcon(Path.GetExtension(path)).Replace("%1", path);
            shortcut.Save();
        }
コード例 #6
0
        private void CreateShortcut(string path)
        {
            var shortcut =
                new WshShell().CreateShortcut(string.Format("{0}\\{1}.lnk",
                                                            Environment.GetFolderPath(Environment.SpecialFolder
                                                                                                 .DesktopDirectory),
                                                            Path.GetFileNameWithoutExtension(path))) as IWshShortcut;

            if (shortcut == null)
            {
                MessageBox.Show("Create shortcut error", "LE", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            shortcut.TargetPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                               "LEProc.exe");
            shortcut.Arguments = String.Format("-run \"{0}\"", path);
            shortcut.WorkingDirectory = Path.GetDirectoryName(path);
            shortcut.WindowStyle = 1;
            shortcut.Description = string.Format("Run {0} with Locale Emulator", Path.GetFileName(path));
            shortcut.IconLocation = AssociationReader.GetAssociatedIcon(Path.GetExtension(path)).Replace("%1", path);
            shortcut.Save();
        }