|
|
|
|
|
CreateShortcut (Function) In french: CréeRaccourci Creates a shortcut on the Windows desktop, in the "Start" menu of Windows or in a specific directory. This shortcut can be associated with any type of file: executable, document, etc. Remark: In Windows Vista and later, to create a shortcut, the application must be started in "Administrator" mode. // Vista/7...: Administrator privileges required // Creates the "Test" shortcut of "C:\Test\Test.exe" program // on the desktop (of all users), with Ctrl + Alt + A as shortcut IF CreateShortCut(shortcutDesktop, "Test", "C:\Test\Test.exe", "",  swsNormal, "A") = False THEN Error("Failure creating the shortcut in" + SysDir(srCommonDesktop) + ... ", check your rights (administrator privileges required)", ErrorInfo()) ELSE Info("The shortcut was created") END // Vista/7...: Administrator privileges required // Create the shortcut in "Start/Programs/Accessories" of all the users IF CreateShortCut(shortcutProgram, "Test", "C:\Test\Test.exe", ... "Accessories", swsNormal, "A") = False THEN Error("Failure creating the shortcut in" + SysDir(srCommonPrograms) + ... ", check your rights (administrator privileges required)", ErrorInfo())  ELSE Info("The shortcut was created") END Syntax
<Result> = CreateShortcut(<Location> , <Name> , <Command line> [, <Shortcut path> [, <Opening mode> [, <Shortcut key> [, <Working directory> [, <Icon>]]]]])
<Result>: Boolean - True if the shortcut was created,
- False if a problem occurred.
<Location>: Integer constant Shortcut location: | | shortcutDesktop (Default value) | Shortcut created on the Windows desktop for all computer users. To create a shortcut on the desktop of Windows Vista (and later), the application that creates the shortcut must have an administrator manifest. | shortcutFindWindows8 | Shortcut created for the search in Windows 8 for all computer users. The shortcut is not found on the home screen. If the system used is not Windows 8, the shortcut is created in the "Start .. Programs" menu of Windows for all computer users. | shortcutFree | Shortcut created in the directory specified by <Path>. | shortcutProgram | Shortcut created in the "Start .. Programs" menu of Windows for all computer users. To create a shortcut in the "Start .. Programs" menu in Windows Vista (and later), the application that creates the shortcut must have an administrator manifest. To create a shortcut on the Programs menu of the current user, use the shortcutFree constant then use SysDir(srPrograms) in <Shortcut path>. In this case, the application that creates the shortcut requires no administrator manifest. | shortcutQuickLaunch | Shortcut created in the quick launch bar (Windows 98 and later). | shortcutStart | Shortcut created in the "Start" menu of Windows for all computer users. | shortcutStartup | Shortcut created in the "Start .. Programs .. Startup" menu of Windows for all computer users. | shortcutUserDesktop | Shortcut created on the Windows desktop for the current computer user. | shortcutUserProgram | Shortcut created in the "Start .. Programs" menu of Windows for the current computer user. | shortcutUserStart | Shortcut created in the "Start" menu of Windows for the current computer user. | shortcutUserStartup | Shortcut created in the "Start .. Programs .. Startup" menu of Windows for the current computer user. |
<Name>: Character string Name of shortcut. <Command line>: Character string Full command line associated with the shortcut. This command line will be run when a double click is performed on the link. The paths of the files containing space characters must be enclosed in quotes. In the shortcut properties, the command line corresponds to the target.
<Shortcut path>: Optional character string Directory into which the shortcut must be created (directory relative to <Location>). The shortcut can be created in a "Directory" (or group of programs) of "Start .. Programs" menu or in a folder on the desktop. If <Location> = shortcutFree, the path is absolute (the disk is specified) ; otherwise, the path is relative to the specified location. If this parameter is not specified or if it corresponds to an empty string (""), the shortcut will be created in the specified <Location>. The paths containing space characters must be enclosed in quotes. <Opening mode>: Optional integer constant Mode for opening the main window of the application associated with the link. The color of the selection bar will be modified for this control (table, list box or combo box). | | swsIconic | Open the minimized window. | swsMaximize | Open the maximized window. | swsNormal (Default value) | Open in standard size. |
<Shortcut key>: Optional character string Key (or combination of keys) allowing you to run the shortcut. Each key is represented by one or more characters. There is no need to specify "Ctrl-Alt" that is automatically added. No shortcut key is specified by default.- To use a single keyboard character, all you have to do is use the character itself. For example, to represent the letter A, assign the value "A" to <Shortcut key>.
Caution: A special meaning is assigned by the function to the following characters:- plus (+),
- insertion (^),
- percentage (%),
- brackets ( ).
To use one of these characters, the character must be enclosed in curly brackets. For example, to use the plus sign (+), type {+}. To use curly brackets, use the {{} and {}} characters. - When using special characters, specific codes are required to identify:
- the characters with no action on the screen (the Enter key for example)
- the characters corresponding to an action (the function keys for example).
You must use the following codes:
| | | | Key | Code | Key | Code |
---|
BACKSPACE | {BS} | PAUSE | {PAUSE} | CAPSLOCK | {VERRMAJ} | DEL | {SUPPR} | DOWN | {DOWN} | END | {END} | ENTER | {ENTER} | ESC | {ECHAP} | HELP | {HELP} | HOME | {HOME} | INSERT | {INS} | LEFT | {LEFT} | NUMLOCK | {NUMLOCK} | PGDN | {PGDN} | PGUP | {PGUP} | PRNT. SCREEN | {PRTSC} | RIGHT | {RIGHT} | SCROLLLOCK | {SCROLLLOCK} | TAB | {TAB} | TOP | {TOP} | F1 | {F1} | F2 | {F2} | F3 | {F3} | F4 | {F4} | F5 | {F5} | F6 | {F6} | F7 | {F7} | F8 | {F8} | F9 | {F9} | F10 | {F10} | F11 | {F11} | F12 | {F12} | F13 | {F13} | F14 | {F14} | F15 | {F15} | F16 | {F16} |
- To specify a key combination with Shift, Ctrl or Alt, the standard key code must be preceded by one or more codes chosen among the following ones:
- To specify that the Shift, Ctrl and/or Alt keys must be hold down while pressing another key: for example, in order for the Shift key to be kept down while pressing the E key, use "+E"
<Working directory>: Optional character string Working directory associated with the program run. No working directory is specified by default. The paths containing space characters must be enclosed in quotes. <Icon>: Optional character string Name and path of the icon associated with the shortcut. The icon of the executable is used by default (or the icon associated with the type of file).
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|