Microsoft KB Archive/824399

= INFO: The SHCreateShortcut Function Requires Quotation Marks in Paths That Contain Spaces =

Article ID: 824399

Article Last Modified on 12/27/2003

-

APPLIES TO


 * Microsoft Windows CE .NET 4.2

-



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 &quot;\Hard Disk\target.exe&quot; with an argument of &quot;-a&quot; could be defined as: LPTSTR szTarget = _T(&quot;\\Hard Disk\\target.exe -a&quot;); The path contains spaces and would therefore need to be surrounded by double quotation marks as follows: LPTSTR szTarget = _T(&quot;\&quot;\\Hard Disk\\target.exe\&quot; -a&quot;); 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.

Additional query words:

Keywords: kbinfo KB824399

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.