This is a Class Builder user object that provides a very thin interface to the Windows 95 Shell COM IShellLink object. The documentation I give here mainly consists of the differences from the Win32 documentation.
This is part of my tcshlutl package.
Please note that Watcom C/C++ 11.0 is required to build the associated DLL, tcshlutl.dll
See u_shell_link_demo for a sample that demonstrates this object.
Test if the underlying IShellLink object was created successfully. If the object was not created successfully call uf_error_code() to get the OLE or Win32 error code.
boolean: Non-zero if the object was created successfully.
u_shell_link uo_shell_link if not uo_shell_link.uf_good() then // error end if
Get the last OLE or Win32 error or result code. This will only be an error code if the object failed to initialise correct (uf_good() returns zero) or if the last function call returned -1.
unsigned long: The last error or result code.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
IShellLink::QueryInterface
to get a
IPersistFile interface and calls Save(szfilename,
false)
on it.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Uses IShellLink::QueryInterface
to get a
IPersistFile interface and calls Load(szfilename)
on it.
Get the path and file for the shortcut
ref string psz_file: where to store the path and filename. The variable passed should be initialised to space(255) or something similar before calling this function.
long cch_max_path: the amount of space available to store the path and filename in.
ulong f_flags: flags that effect the returned path. If
SLGP_SHORTPATH
is set then the filename will be returned in
8.3 form. If SLGP_UNCPRIORITY
is set then a UNC path will be
returned. These have been defined as global constants in u_shell_link.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Get the icon location for the shortcut
ref string psz_icon_path: where to store the path to the file containing the icon. The variable passed should be initialised to space(255) or something similar before calling this function.
long cch_max_path: the amount of space available to store the icon path in.
ref long pi_icon: the index of the icon is returned here.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Set the description string for the shortcut. This doesn't seem to be used for anything.
string psz_name: the description string
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Set the hotkey for the shortcut.
unsignedinteger w_hotkey: the hotkey. This has the virtual key-code in the low-order byte and a combination of modifiers in the high-order byte.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Set the way that the application referred to by the shortcut will display itself (the Run item in Shortcut properties
integer i_show_cmd: the ShowWindow()
value. See the ShowCmd values table.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Set the working directory for the shortcut.
string psz_dir: the new working directory for the shortcut
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Get the shortcuts hotkey
unsignedinteger pw_hotkey: the hotkey is returned here. This will have the virtual key-code in the low-order byte and a combination of modifiers
in the high-order byte.integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Get the window show command for the shortcut
ref integer pi_show_cmd: the ShowWindow value is returned in this variable. See the ShowCmds table for a list of commands.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Get the command-line arguments for the shortcut
ref string psz_args: where to store the arguments. The variable passed should be initialised to space(255) or something similar before calling this function.
long cch_max_path: the amount of space available to store the arguments in.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
// assuming "u_shell_link uo_shell_link" somewhere string s_args s_args = space(255) if uo_shell_link.uf_get_arguments(s_args, len(s_args)) = 1 then // success else // error end if
Get the description field from the shortcut. Windows doesn't seem to use this for anything.
ref string psz_name: where to store the description. The variable passed should be initialised to space(255) or something similar before calling this function.
long cch_max_path: the amount of space available to store the description in.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
// assuming "u_shell_link uo_shell_link" somewhere string s_desc s_desc = space(255) if uo_shell_link.uf_get_description(s_desc, len(s_desc)) = 1 then // success else // error end if
Get the working directory from the shortcut.
ref string psz_dir where to store the working directory. The variable passed should be initialised to space(255) or something similar before calling this function.
long cch_max_path: the amount of space available to store the working directory in.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
Attempts to resolve the shortcut to it's destination. See the Win32 SDK help documentation for details.
ulong hwnd: handle of a window used as an owner window for a dialog box
ulong f_flags: action flags.
integer: 1 on success, -1 on failure, check uf_error_code() for an OLE error code.
These are used in the high-order byte of the hotkey values supplied to uf_set_hotkey() and received from uf_get_hotkey()
These have been defined as global constants in the u_shell_link user object.
Value | Modifier key |
---|---|
HOTKEYF_ALT | ALT key |
HOTKEYF_CONTROL | Control key |
HOTKEYF_EXT | Extended key (eg. keypad) |
HOTKEYF_SHIFT | Shift key |
These are values supplied to the uf_set_show_cmd() and the result from the uf_get_show_cmd() functions.
These have been defined as global constants in the u_shell_link user object.
Value | Window disposition |
---|---|
SW_SHOWNORMAL | Normal |
SW_SHOWMAXIMIZED | Maximized |
SW_SHOWMINNOACTIVE | Minimized |
As simple example that creates a shortcut
// This is a bit light on error checkingA simple example that reads in a shortcut
// This is a bit light on error checking