Esempio n. 1
0
        public static ShellLink CreateShortcut(string shortcutPath, string actualFilePath, string description = null, string workingDirectory = null, string arguments = null)
        {
            shortcutPath   = shortcutPath.GetFullPath();
            actualFilePath = actualFilePath.GetFullPath();
            if (!System.IO.Path.HasExtension(shortcutPath))
            {
                shortcutPath += ".LNK";
            }

            var link = new ShellLink(shortcutPath);

            link.Path = actualFilePath;

            link.WorkingDirectory = workingDirectory ?? System.IO.Path.GetDirectoryName(actualFilePath);

            if (description != null)
            {
                link.Description = description;
            }

            if (arguments != null)
            {
                link.Arguments = arguments;
            }

            link.Save(shortcutPath);
            return(link);
        }
Esempio n. 2
0
        /// <summary>
        ///     Load a shortcut from a file.
        /// </summary>
        /// <param name="linkPath"> A path to the file. </param>
        public static ShellLink Load(string linkPath)
        {
            var result = new ShellLink();

            ((IPersistFile)result.shellLink).Load(linkPath, (int)STGM_FLAGS.STGM_READ);
            result.ReadConsoleProperties();
            return(result);
        }
Esempio n. 3
0
        public static ShellLink CreateShortcut(string shortcutPath, string actualFilePath, string description = null, string workingDirectory = null, string arguments = null) {
            shortcutPath = shortcutPath.GetFullPath();
            actualFilePath = actualFilePath.GetFullPath();
            if (!System.IO.Path.HasExtension(shortcutPath)) {
                shortcutPath += ".LNK";
            }

            var link = new ShellLink(shortcutPath);
            link.Path = actualFilePath;

            link.WorkingDirectory = workingDirectory ?? System.IO.Path.GetDirectoryName(actualFilePath);

            if (description != null) {
                link.Description = description;
            }

            if (arguments != null) {
                link.Arguments = arguments;
            }

            link.Save(shortcutPath);
            return link;
        }
Esempio n. 4
0
 /// <summary>
 ///     Load a shortcut from a file.
 /// </summary>
 /// <param name="linkPath"> A path to the file. </param>
 public static ShellLink Load(string linkPath) {
     var result = new ShellLink();
     ((IPersistFile)result.shellLink).Load(linkPath, (int)STGM_FLAGS.STGM_READ);
     result.ReadConsoleProperties();
     return result;
 }
Esempio n. 5
0
 /// <summary>
 ///     This should be only called by a ShellLink constructor
 /// </summary>
 /// <param name="owner"> </param>
 internal ConsoleProperties(ShellLink owner)
     : this()
 {
     this.owner = owner;
 }
 /// <summary>
 ///     This should be only called by a ShellLink constructor
 /// </summary>
 /// <param name="owner"> </param>
 internal ConsoleProperties(ShellLink owner)
     : this() {
     this.owner = owner;
 }