/// <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, EShellLinkResolveFlags resolveFlags, ushort timeOut ) { uint flags; if ((resolveFlags & EShellLinkResolveFlags.SLR_NO_UI) == EShellLinkResolveFlags.SLR_NO_UI) { flags = (uint)((int)resolveFlags | (timeOut << 16)); } else { flags = (uint)resolveFlags; } 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; } }
/// <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, EShellLinkResolveFlags resolveFlags) { Open(linkFile, hWnd, resolveFlags, 1); }
public void Open(string linkFile, IntPtr hWnd, EShellLinkResolveFlags resolveFlags, ushort timeOut) { uint fFlags = ((resolveFlags & EShellLinkResolveFlags.SLR_NO_UI) != EShellLinkResolveFlags.SLR_NO_UI) ? ((uint)resolveFlags) : ((uint)(resolveFlags | ((EShellLinkResolveFlags)(timeOut << 0x10)))); if (this.linkA == null) { ((IPersistFile)this.linkW).Load(linkFile, 0); this.linkW.Resolve(hWnd, fFlags); this.shortcutFile = linkFile; } else { ((IPersistFile)this.linkA).Load(linkFile, 0); this.linkA.Resolve(hWnd, fFlags); this.shortcutFile = linkFile; } }
/// <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 static ShellLink FromFile(string linkFile, IntPtr hWnd, EShellLinkResolveFlags resolveFlags, ushort timeOut) { uint flags; if ((resolveFlags & EShellLinkResolveFlags.SLR_NO_UI) == EShellLinkResolveFlags.SLR_NO_UI) { flags = (uint)((int)resolveFlags | (timeOut << 16)); } else { flags = (uint)resolveFlags; } var ret = new ShellLink(); if (ret.Wrapped.IsPersistFile(out var Persist)) { Persist.Load(linkFile, 0); //STGM_DIRECT) ret.Wrapped.Resolve(hWnd, flags); } return(ret); }
/// <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, EShellLinkResolveFlags resolveFlags ) { Open(linkFile, hWnd, resolveFlags, 1); }
/// <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 static ShellLink FromFile(string linkFile, IntPtr hWnd, EShellLinkResolveFlags resolveFlags) { return(FromFile(linkFile, hWnd, resolveFlags, 1)); }