Пример #1
0
        /// <summary>Loads a shortcut from the specified file, and allows flags controlling
        /// the UI behaviour if the shortcut's target isn't found to be set.  If
        /// no SLR_NO_UI is specified, you can also specify a timeout.</summary>
        /// <param name="linkFile">The shortcut file (.lnk) to load</param>
        /// <param name="hWnd">The window handle of the application's UI, if any</param>
        /// <param name="resolveFlags">Flags controlling resolution behaviour</param>
        /// <param name="timeOut">Timeout if SLR_NO_UI is specified, in ms.</param>
        public void Open(string linkFile, IntPtr hWnd, ShellLinkResolutionBehavior resolutionBehavior, ushort timeOut)
        {
            uint flags;

            if ((resolutionBehavior & ShellLinkResolutionBehavior.NoUI) == ShellLinkResolutionBehavior.NoUI)
            {
                flags = (uint)((int)resolutionBehavior | (timeOut << 16));
            }
            else
            {
                flags = (uint)resolutionBehavior;
            }

            if (linkA == null)
            {
                ((IPersistFile)linkW).Load(linkFile, 0);                 //STGM_DIRECT)
                linkW.Resolve(hWnd, flags);
                this.shortcutFile = linkFile;
            }
            else
            {
                ((IPersistFile)linkA).Load(linkFile, 0);                 //STGM_DIRECT)
                linkA.Resolve(hWnd, flags);
                this.shortcutFile = linkFile;
            }
        }
Пример #2
0
 /// <summary>Loads a shortcut from the specified file, and allows flags controlling
 /// the UI behaviour if the shortcut's target isn't found to be set.</summary>
 /// <param name="linkFile">The shortcut file (.lnk) to load</param>
 /// <param name="hWnd">The window handle of the application's UI, if any</param>
 /// <param name="resolveFlags">Flags controlling resolution behaviour</param>
 public void Open(string linkFile, IntPtr hWnd, ShellLinkResolutionBehavior resolutionBehavior)
 {
     Open(linkFile, hWnd, resolutionBehavior, 1);
 }