SHCreateShortcutEx (Windows CE 5.0)
This function automatically creates a uniquely named shortcut in a specified directory. The name is based on the target of the shortcut.
Syntax
DWORD WINAPI SHCreateShortcutEx( LPTSTR lpszDir, LPTSTR lpszTarget, LPTSTR szShortcut, LPDWORD lpcbShortcut);
Parameters
lpszDir
[in] Null-terminated string that contains the path and name of the shortcut to create.lpszTarget
[in] Pointer to a null-terminated string that contains the target path and arguments for the shortcut. The size of the buffer is limited to 256 characters. Place quotes around the target path so that SHCreateShortcutEx can correctly parse the target file from any following arguments, for example:"\\My Computer\Program Files\app.exe" /r file.txt
szShortcut
[out] Null-terminated string containing the unique name that SHCreateShortcutEx created for the shortcut.Set this parameter to NULL if you do not want the shortcut name returned.
lpcbShortcut
[out] Pointer to the maximum allowable size for szShortcut. If the name that SHCreateShortcutEx creates for the shortcut is longer than the length specified in this parameter*,* then the function will fail and the length of the name that would have been used will be returned in lpcbShortcut.Set this parameter to NULL if you do not want the length of szShortcut returned.
Return Values
This function is not prototyped correctly in Shellapi.h. It returns a BOOL instead of a DWORD. TRUE indicates success. FALSE indicates failure.
**Note **For Windows Mobile, this function will fail if a file with the target shortcut filename already exists.
To obtain extended error information, call the GetLastError function.
Code Example
The following code example demonstrates how to use SHCreateShortcutEx.
Note To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.
BOOL SHCreateShortcutExExample()
{
// Create a shortcut to the file \Windows\Program Files\myApp.exe
// in \Windows\myPath, with a maximum allowable shortcut name length of 64.
// If successful, myAppShortcut will contain the name of the shortcut.
DWORD maxLen = 64;
LPTSTR myAppShortcut = new TCHAR[maxLen + 1];
return SHCreateShortcutEx(TEXT("\\Windows\\MyPath"),
TEXT("\\Windows\\Program Files\\myApp.exe"),
myAppShortcut,
&maxLen);
}
Requirements
OS Versions: Windows CE .NET 4.2 and later.
Header: Shellapi.h.
Link Library: Coredll.lib.
See Also
Send Feedback on this topic to the authors