INFO: The SHCreateShortcut() Function Requires Quotation Marks in Paths That Contain Spaces (824399)



The information in this article applies to:

  • Microsoft Windows CE .NET Operating System

SUMMARY

You can use the SHCreateShortcut() API call to create a shortcut file that references a file in another location. If the file that is being referenced (the target) has a space in either the file name or the path, you must enclose the combined path and file name in double quotation marks.

MORE INFORMATION

The target that is specified in the SHCreateShortcut() call may contain parameters that are passed to the target when the call is started by means of the shortcut. Because spaces are used as a delimiter between the target command and its parameters, any spaces in the target command (including the path) must be enclosed in double quotation marks.

For example, the C string representing the path "\Hard Disk\target.exe" with an argument of "-a" could be defined as:
LPTSTR szTarget = _T("\\Hard Disk\\target.exe -a");
The path contains spaces and would therefore need to be surrounded by double quotation marks as follows:
LPTSTR szTarget = _T("\"\\Hard Disk\\target.exe\" -a");
Note If you do not enclose this path in double quotation marks, and if you try to use this link, the system will try to launch a non-existant program named \Hard.

Modification Type:MinorLast Reviewed:12/27/2003
Keywords:kbinfo KB824399 kbAudDeveloper