Skip to main content

ShellLink class

Namespace: Velopack.Windows

Summary description for ShellLink.

[ExcludeFromCodeCoverage]
public class ShellLink : IDisposable

Implements: IDisposable

Constructors

ConstructorSummary
ShellLinkCreates an instance of the Shell Link object.
ShellLinkCreates an instance of a Shell Link object
public ShellLink()

Creates an instance of the Shell Link object.

public ShellLink(string linkFile)

Creates an instance of a Shell Link object from the specified link file

Parameters

NameTypeDescription
linkFilestringThe Shortcut file to open

Properties

PropertySummary
ShortCutFile
IconPathGets the path to the file containing the icon for this shortcut.
IconIndexGets the index of this icon within the icon path's resources
TargetGets/sets the fully qualified path to the link's target
WorkingDirectoryGets/sets the Working Directory for the Link
DescriptionGets/sets the description of the link
ArgumentsGets/sets any command line arguments associated with the link
DisplayModeGets/sets the initial display mode when the shortcut is
HotKeyGets/sets the HotKey to start the shortcut (if any)

ShortCutFile

public string ShortCutFile { get; set; }

IconPath

public string IconPath { get; set; }

Gets the path to the file containing the icon for this shortcut.

IconIndex

public int IconIndex { get; set; }

Gets the index of this icon within the icon path's resources

Target

public string Target { get; set; }

Gets/sets the fully qualified path to the link's target

WorkingDirectory

public string WorkingDirectory { get; set; }

Gets/sets the Working Directory for the Link

Description

public string Description { get; set; }

Gets/sets the description of the link

Arguments

public string Arguments { get; set; }

Gets/sets any command line arguments associated with the link

DisplayMode

public ShellLink.LinkDisplayMode DisplayMode { get; set; }

Gets/sets the initial display mode when the shortcut is run

HotKey

public short HotKey { get; set; }

Gets/sets the HotKey to start the shortcut (if any)

Methods

MethodSummary
~ShellLinkCall dispose just in case it hasn't happened yet
DisposeDispose the object, releasing the COM ShellLink object
GetIconThis pointer must be destroyed with DistroyIcon when you are done with it.
SetAppUserModelIdSets the appUserModelId
SetToastActivatorCLSIDSets the ToastActivatorCLSID
SetToastActivatorCLSIDSets the ToastActivatorCLSID
SaveSaves the shortcut to ShortCutFile.
SaveSaves the shortcut to the specified file
OpenLoads a shortcut from the specified file
OpenLoads a shortcut from the specified file, and allows flags controlling
OpenLoads a shortcut from the specified file, and allows flags controlling
protected ~ShellLink()

Call dispose just in case it hasn't happened yet

Dispose()

public void Dispose()

Dispose the object, releasing the COM ShellLink object

GetIcon(large)

public nint GetIcon(bool large)

This pointer must be destroyed with DistroyIcon when you are done with it.

Parameters

NameTypeDescription
largeboolWhether to return the small or large icon

Returns nint

SetAppUserModelId(appId)

public void SetAppUserModelId(string appId)

Sets the appUserModelId

Parameters

NameTypeDescription
appIdstring

SetToastActivatorCLSID(clsid)

public void SetToastActivatorCLSID(string clsid)

Sets the ToastActivatorCLSID

Parameters

NameTypeDescription
clsidstring

SetToastActivatorCLSID(clsid)

public void SetToastActivatorCLSID(Guid clsid)

Sets the ToastActivatorCLSID

Parameters

NameTypeDescription
clsidGuid

Save()

public void Save()

Saves the shortcut to ShortCutFile.

Save(linkFile)

public void Save(string linkFile)

Saves the shortcut to the specified file

Parameters

NameTypeDescription
linkFilestringThe shortcut file (.lnk)

Open(linkFile)

public void Open(string linkFile)

Loads a shortcut from the specified file

Parameters

NameTypeDescription
linkFilestringThe shortcut file (.lnk) to load

Open(linkFile, hWnd, resolveFlags)

public void Open(string linkFile, nint hWnd, ShellLink.EShellLinkResolveFlags resolveFlags)

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.

Parameters

NameTypeDescription
linkFilestringThe shortcut file (.lnk) to load
hWndnintThe window handle of the application's UI, if any
resolveFlagsShellLink.EShellLinkResolveFlagsFlags controlling resolution behaviour

Open(linkFile, hWnd, resolveFlags, timeOut)

public void Open(string linkFile, nint hWnd, ShellLink.EShellLinkResolveFlags resolveFlags, ushort timeOut)

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.

Parameters

NameTypeDescription
linkFilestringThe shortcut file (.lnk) to load
hWndnintThe window handle of the application's UI, if any
resolveFlagsShellLink.EShellLinkResolveFlagsFlags controlling resolution behaviour
timeOutushortTimeout if SLR_NO_UI is specified, in ms.

Generated from Velopack 1.1.1