Example #1
0
        /// <summary>Initializes a new instance of the <see cref="ShellLink"/> class, which acts as a wrapper for a .lnk file.</summary>
        /// <param name="linkFile">The shortcut file (.lnk) to load.</param>
        /// <param name="window">
        /// The window that the Shell will use as the parent for a dialog box. The Shell displays the dialog box if it needs to prompt the user for more
        /// information while resolving a Shell link.
        /// </param>
        /// <param name="resolveFlags">The resolve flags.</param>
        /// <param name="timeOut">The time out.</param>
        /// <exception cref="System.ArgumentNullException">linkFile</exception>
        public ShellLink(string linkFile, IWin32Window window = null, LinkResolution resolveFlags = LinkResolution.AnyMatch | LinkResolution.NoUI, ushort timeOut = 1) : this()
        {
            if (string.IsNullOrEmpty(linkFile))
            {
                throw new ArgumentNullException(nameof(linkFile));
            }

            if ((resolveFlags & LinkResolution.NoUI) == LinkResolution.NoUI)
            {
                resolveFlags |= (LinkResolution)(timeOut << 16);
            }

            Init(linkFile);
            new FileIOPermission(FileIOPermissionAccess.Read, FullPath).Demand();
            ((IPersistFile)link).Load(linkFile, 0);             //STGM_DIRECT)
            link.Resolve(window?.Handle ?? IntPtr.Zero, (uint)resolveFlags);
        }
Example #2
0
 /// <summary>Initializes a new instance of the <see cref="ShellLink"/> class, which acts as a wrapper for a .lnk file.</summary>
 /// <param name="linkFile">The shortcut file (.lnk) to load.</param>
 /// <param name="window">
 /// The window that the Shell will use as the parent for a dialog box. The Shell displays the dialog box if it needs to prompt the
 /// user for more information while resolving a Shell link.
 /// </param>
 /// <param name="resolveFlags">The resolve flags.</param>
 /// <param name="timeOut">The time out.</param>
 /// <exception cref="System.ArgumentNullException">linkFile</exception>
 public ShellLink(string linkFile, LinkResolution resolveFlags = LinkResolution.NoUI, IWin32Window window = null, TimeSpan timeOut = default) : base(linkFile) =>
Example #3
0
 /// <summary>Initializes a new instance of the <see cref="ShellLink"/> class, which acts as a wrapper for a .lnk file.</summary>
 /// <param name="linkFile">The shortcut file (.lnk) to load.</param>
 /// <param name="window">
 /// The window that the Shell will use as the parent for a dialog box. The Shell displays the dialog box if it needs to prompt the
 /// user for more information while resolving a Shell link.
 /// </param>
 /// <param name="resolveFlags">The resolve flags.</param>
 /// <param name="timeOut">The time out.</param>
 /// <exception cref="System.ArgumentNullException">linkFile</exception>
 public ShellLink(string linkFile, LinkResolution resolveFlags = LinkResolution.NoUI, HWND window = default, TimeSpan timeOut = default) : base(linkFile) =>
Example #4
0
 /// <summary>Initializes a new instance of the <see cref="ShellLink"/> class, which acts as a wrapper for a .lnk file.</summary>
 /// <param name="linkFile">The shortcut file (.lnk) to load.</param>
 /// <param name="window">
 /// The window that the Shell will use as the parent for a dialog box. The Shell displays the dialog box if it needs to prompt the
 /// user for more information while resolving a Shell link.
 /// </param>
 /// <param name="resolveFlags">The resolve flags.</param>
 /// <param name="timeOut">The time out.</param>
 /// <exception cref="System.ArgumentNullException">linkFile</exception>
 public ShellLink(string linkFile, LinkResolution resolveFlags = LinkResolution.NoUI, IWin32Window window = null, TimeSpan timeOut = default) : base(linkFile) => LoadAndResolve(linkFile, (SLR_FLAGS)resolveFlags, ShellFolder.IWin2Ptr(window), (ushort)timeOut.TotalMilliseconds);