Class Shortcut
The Shortcut class can be used to process & create Shell Link Binary File Format files. In this format a structure is called a shell link, or shortcut, and is a data object that contains information that can be used to access another data object. The Shell Link Binary File Format is the format of Windows files with the extension "LNK".
Shell links are commonly used to support application launching and linking scenarios, such as Object Linking and Embedding(OLE), but they also can be used by applications that need the ability to store a reference to a target file.
Inherited Members
Namespace: SharpShellLink
Assembly: SharpShellLink.dll
Syntax
public class Shortcut : ShellLinkHeader
Constructors
| Edit this page View SourceShortcut()
Constructor
Declaration
public Shortcut()
Properties
| Edit this page View SourceExtraData
EXTRA_DATA: Zero or more ExtraData structures.
Declaration
public ExtraData ExtraData { get; set; }
Property Value
| Type | Description |
|---|---|
| ExtraData |
LinkFlags
LinkFlags (4 bytes): A LinkFlags structure that specifies information about the shell link and the presence of optional portions of the structure.
Declaration
public override LinkFlags LinkFlags { get; }
Property Value
| Type | Description |
|---|---|
| LinkFlags |
Overrides
| Edit this page View SourceLinkInfo
LINKINFO: An optional LinkInfo structure, which specifies information necessary to resolve the link target. The presence of this structure is specified by the HasLinkInfo bit in the ShellLinkHeader.
Declaration
public LinkInfo? LinkInfo { get; set; }
Property Value
| Type | Description |
|---|---|
| LinkInfo |
LinkTargetIDList
LINKTARGET_IDLIST: An optional LinkTargetIDList structure, which specifies the target of the link. The presence of this structure is specified by the HasLinkTargetIDList bit in the ShellLinkHeader.
Declaration
public LinkTargetIDList? LinkTargetIDList { get; set; }
Property Value
| Type | Description |
|---|---|
| LinkTargetIDList |
ShellLinkHeader
SHELL_LINK_HEADER: A ShellLinkHeader structure, which contains identification information, timestamps, and flags that specify the presence of optional structures.
Declaration
public ShellLinkHeader ShellLinkHeader { get; }
Property Value
| Type | Description |
|---|---|
| ShellLinkHeader |
Size
The size of the ShellLink in bytes
Declaration
public int Size { get; }
Property Value
| Type | Description |
|---|---|
| int |
StringData
STRING_DATA: Zero or more optional StringData structures, which are used to convey user interface and path identification information. The presence of these structures is specified by bits in the ShellLinkHeader.
Declaration
public StringData? StringData { get; set; }
Property Value
| Type | Description |
|---|---|
| StringData |
Methods
| Edit this page View SourceCreateShortcut(string)
Create a new Shelllink (shortcut)
Declaration
public static Shortcut CreateShortcut(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path the shortcut points to |
Returns
| Type | Description |
|---|---|
| Shortcut | Shortcut object |
CreateShortcut(string, string)
Create a new Shelllink (shortcut)
Declaration
public static Shortcut CreateShortcut(string path, string args)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path the shortcut points to |
| string | args | Command line arguments |
Returns
| Type | Description |
|---|---|
| Shortcut | Shortcut object |
CreateShortcut(string, string, int)
Create a new Shelllink (shortcut)
Declaration
public static Shortcut CreateShortcut(string path, string iconpath, int iconindex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path the shortcut points to |
| string | iconpath | Path to the file containing the icon |
| int | iconindex | Index ot the icon |
Returns
| Type | Description |
|---|---|
| Shortcut | Shortcut object |
CreateShortcut(string, string, string)
Create a new Shelllink (shortcut)
Declaration
public static Shortcut CreateShortcut(string path, string args, string workdir)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path the shortcut points to |
| string | args | Command line arguments |
| string | workdir | Working directory |
Returns
| Type | Description |
|---|---|
| Shortcut | Shortcut object |
CreateShortcut(string, string, string, int)
Create a new Shelllink (shortcut)
Declaration
public static Shortcut CreateShortcut(string path, string args, string iconpath, int iconindex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path the shortcut points to |
| string | args | Command line arguments |
| string | iconpath | Path to the file containing the icon |
| int | iconindex | Index ot the icon |
Returns
| Type | Description |
|---|---|
| Shortcut | Shortcut object |
CreateShortcut(string, string, string, string, int)
Create a new Shelllink (shortcut)
Declaration
public static Shortcut CreateShortcut(string path, string args, string workdir, string iconpath, int iconindex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path the shortcut points to |
| string | args | Command line arguments |
| string | workdir | Working directory |
| string | iconpath | Path to the file containing the icon |
| int | iconindex | Index ot the icon |
Returns
| Type | Description |
|---|---|
| Shortcut | Shortcut object |
FromByteArray(byte[])
Create a ShellLing from a given byte array
Declaration
public static Shortcut FromByteArray(byte[] ba)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | ba | The byte array |
Returns
| Type | Description |
|---|---|
| Shortcut | A Shortcut object |
GetBytes()
Convert the Structure to a byte array
Declaration
public override byte[] GetBytes()
Returns
| Type | Description |
|---|---|
| byte[] | Byte array representation of the Structure |
Overrides
| Edit this page View SourceReadFromFile(string)
Reads a lnk and returns a Shortcut object
Declaration
public static Shortcut ReadFromFile(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the lnk file |
Returns
| Type | Description |
|---|---|
| Shortcut | Shortcut object |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string that represents the current object. |
Overrides
| Edit this page View SourceWriteToFile(string)
Writes Shortcut object to a file
Declaration
public void WriteToFile(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Target lnk path |