Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 3
0
 /// <summary>
 ///   This should be only called by a ShellLink constructor
 /// </summary>
 /// <param name = "owner"></param>
 internal ConsoleProperties(ShellLink owner)
     : this()
 {
     this.owner = owner;
 }
Ejemplo 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;
 }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
 /// <summary>
 ///   This should be only called by a ShellLink constructor
 /// </summary>
 /// <param name="owner"> </param>
 internal ConsoleProperties(ShellLink owner)
     : this()
 {
     this.owner = owner;
 }