Help Center
Help CenterAfxNovaWindows

Shortcut Classes

Members (15)

Documentation

Shortcut Classes

CShortcut allows to create a shortcut programmatically.

CURLShortcut allows to create a URL shortcut programmatically.

Include file: AfxNova/CShortcut.inc


Constructors

CONSTRUCTOR CShortcut (BYREF wszPathName AS WSTRING)
ParameterDescription
wszPathNameThe full path and file name of the shortcut.
Example
' Creates a shortcut programatically (if it already exists, opens it)
DIM pShortcut AS CShortcut = ExePath & "\Test.lnk"   ' --> change me
' Sets various properties and saves them to disk
pShortcut.Description = "Hello world"   ' --> change me
pShortcut.WorkingDirectory = ExePath & "\"   ' --> change me
pShortcut.Arguments = "/c"   ' --> change me
pShortcut.HotKey = "Ctrl+Alt+e"   ' --> change me
pShortcut.IconLocation = ExePath & "\Program.ico,0"   ' --> change me
pShortcut.RelativePath = ExePath & "\"   ' --> change me
pShortcut.TargetPath = ExePath & $"\HelloWord.exe"   ' --> change me
pShortcut.WindowStyle = WshNormalFocus
pShortcut.Save
CONSTRUCTOR CURLShortcut (BYREF wszPathName AS WSTRING)
ParameterDescription
wszPathNameThe full path and file name of the shortcut.
' Creates a shortcut programatically (if it already exists, opens it)
DIM pURLShortcut AS CURLShortcut = ExePath & "\Microsoft Web Site.url"   ' --> change me
pURLShortcut.TargetPath = "http://www.microsoft.com"   ' --> change me
pURLShortcut.Save

CShortcut Methods

NameDescription
SaveSaves a shortcut object to disk.
GetLastResultReturns the last result code.
GetErrorInfoReturns a localized description of the specified error code.

CShortcut Properties

NameDescription
ArgumentsGets/sets the arguments for a shortcut, or identifies a shortcut's arguments.
DescriptionReturns or sets a shortcut's description.
FullNameReturns the fully qualified path of the shortcut object's target.
HotkeyAssigns a key-combination to a shortcut, or identifies the key-combination assigned to a shortcut.
IconLocationAssigns a an icon to a shortcut, or identifies the icon assigned to a shortcut.
RelativePathAssigns a relative path to a shortcut.
TargetPathGets/sets the path of the shortcut's executable.
WindowStyleAssigns a window style to a shortcut, or identifies the type of window style used by a shortcut.
WorkingDirectoryAssigns a working directory to a shortcut, or identifies the working directory used by a shortcut.

CURLShortcut Methods

NameDescription
SaveSaves a URL shortcut object to disk.
GetLastResultReturns the last result code.
GetErrorInfoReturns a localized description of the specified error code.

CShortcut Properties

NameDescription
FullNameReturns the fully qualified path of the shortcut object's target.
TargetPathGets/sets the path of the shortcut's executable.

Save (CShortcut)

Saves a shortcut object to disk.

FUNCTION Save () AS HRESULT
Remarks

After creating an instance of the CShortcut* class to create to create a shortcut object and set the shortcut object's properties, the Save method must be used to save the shortcut object to disk. The **Save method uses the information in the shortcut object's FullName property to determine where to save the shortcut object on a disk. You can only create shortcuts to system objects. This includes files, directories, and drives (but does not include printer links or scheduled tasks).

Return value

HRESULT. S_OK (0) on success, or an error code on failure.


Save (CURLShortcut)

Saves a URL shortcut object to disk.

FUNCTION Save () AS HRESULT
Remarks

After creating an instance of the CURLShortcut class to create to create a shortcut object and set the shortcut object's properties, the Save method must be used to save the shortcut object to disk. The Save method uses the information in the shortcut object's FullName property to determine where to save the shortcut object on a disk. You can only create shortcuts to system objects. This includes files, directories, and drives (but does not include printer links or scheduled tasks).

Return value

HRESULT. S_OK (0) on success, or an error code on failure.


GetLastResult

Returns the last result code.

FUNCTION GetLastResult () AS HRESULT
Return value

HRESULT. S_OK (0) on success, or an error code on failure.


GetErrorInfo

Returns a localized description of the specified error code. If the error is omited, it will return the value returned by GetLastResult.

FUNCTION GetErrorInfo (BYVAL nError AS LONG = -1) AS DWSTRING

Arguments

Gets/sets the arguments for a shortcut, or identifies a shortcut's arguments.

PROPERTY Arguments () AS DWSTRING
PROPERTY Arguments (BYREF wszArguments AS WSTRING)
ParameterDescription
wszArgumentsThe arguments for the shortcut.
Return value

The arguments of the shortcut.


Description

Returns or sets a shortcut's description.

PROPERTY Description () AS DWSTRING
PROPERTY Description (BYREF wszDescription AS WSTRING)
ParameterDescription
wszDescriptionA string value describing a shortcut.
Return value

The description of the shortcut.


FullName (CShortcut)

Returns the fully qualified path of the shortcut object's target.

PROPERTY FullName () AS DWSTRING
Remarks

The FullName property contains a read-only string value indicating the fully qualified path to the shortcut's target.


FullName (CURLShortcut)

Returns the fully qualified path of the shortcut object's target.

PROPERTY FullName () AS DWSTRING
Remarks

The FullName property contains a read-only string value indicating the fully qualified path to the shortcut's target.


Hotkey

Assigns a key-combination to a shortcut, or identifies the key-combination assigned to a shortcut.

PROPERTY Hotkey () AS DWSTRING
PROPERTY Hotkey (BYREF wszHotkey AS WSTRING)
ParameterDescription
wszHotkeyA string representing the key-combination to assign to the shortcut.
Return value

The hotkey of the shortcut.


IconLocation

Assigns a an icon to a shortcut, or identifies the icon assigned to a shortcut.

PROPERTY IconLocation () AS DWSTRING
PROPERTY IconLocation (BYREF wszIconLocation AS WSTRING)
ParameterDescription
wszIconLocationA string that locates the icon. The string should contain a fully qualified path and an index associated with the icon.
Return value

The location of the icon.


RelativePath

Assigns a relative path to a shortcut.

PROPERTY RelativePath (BYREF wszRelativePath AS WSTRING)
ParameterDescription
wszRelativePathA string containing the relative path.

TargetPath (CShortcut)

Gets/sets the path of the shortcut's executable.

PROPERTY TargetPath () AS DWSTRING
PROPERTY TargetPath (BYREF wszTargetPath AS WSTRING)
ParameterDescription
wszTargetPathA string containing the path of the shortcut's executable.
Return value

The path of the shortcut's executable.


TargetPath (CURLShortcut)

Gets/sets the path of the shortcut's executable.

PROPERTY TargetPath () AS DWSTRING
PROPERTY TargetPath (BYREF wszTargetPath AS WSTRING)
ParameterDescription
wszTargetPathA string containing the path of the shortcut's executable.
Return value

The path of the shortcut's executable.


WindowStyle

Assigns a window style to a shortcut, or identifies the type of window style used by a shortcut.

PROPERTY WindowStyle () AS LONG
PROPERTY WindowStyle (BYVAL nWindowStyle AS LONG)
ParameterDescription
nWindowStyleThe window style for the program being run.

The following table lists the available settings for nWindowStyle.

StyleDescription
1Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position.
3Activates the window and displays it as a maximized window.
7Minimizes the window and activates the next top-level window.
Return value

LONG. The window style.


WorkingDirectory

Assigns a working directory to a shortcut, or identifies the working directory used by a shortcut.

PROPERTY WorkingDirectory () AS DWSTRING
PROPERTY WorkingDirectory (BYREF wszWorkingDirectory AS WSTRING)
ParameterDescription
wszWorkingDirectoryDirectory in which the shortcut starts.
Return value

The working directory of the shortcut.