AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones varias de Windows
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
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.
Note: On Windows Vista and above, to create a shortcut, the application must be launched 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
Sintaxis
<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.
shortcutFindWindows8Shortcut 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.
shortcutFreeShortcut created in the directory specified with <Path>.
shortcutProgramShortcut 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.
shortcutQuickLaunchShortcut created in the quick launch bar (Windows 98 and later).
shortcutStartShortcut created in the "Start" menu of Windows for all computer users.
shortcutStartupShortcut created in the "Start .. Programs .. Startup" menu of Windows for all computer users.
shortcutUserDesktopShortcut created on the Windows desktop for the current computer user.
shortcutUserProgramShortcut created in the "Start .. Programs" menu of Windows for the current computer user.
shortcutUserStartShortcut created in the "Start" menu of Windows for the current computer user.
shortcutUserStartupShortcut 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 is 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).
swsIconicOpen the minimized window.
swsMaximizeOpen 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: The function gives a special meaning to the following signs:
    • 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:
    KeyCodeKeyCode
    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:
    KeyCode
    SHIFT+
    Ctrl^
    Alt%
  • To specify that the Shift, Ctrl and/or Alt keys are to be held down while another key is pressed: for example, to hold down the Shift key at the same time as 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).
Componente: wd300std.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Exemplo
PROCEDURE CreateShortcuts()

gsProcedure = "CreateShortcuts"

//Trace("CreateShortcuts")

//CRIA O ATALHO NA TELA

sShortcut_Name is string = "Tarifador"

sShortcut_Path is string = fCurrentDir()+fSep()

sShortcut_Command is string = fCurrentDir()+fSep()+"Tarifador.exe"

//CreateShortCut()

IF Contains(sShortcut_Command,"\EXE\",IgnoreCase) = False

IF fFileExist(sShortcut_Command) = True THEN

//Criar Autorun no Registro
RegistrySetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\", sShortcut_Name, sShortcut_Command)

//C:\Users\ADRIANO\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\

Usuario is string = Upper(NetworkUser())

sDirStartup is string = "C:\Users\"+NoSpace(Usuario)+"\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
sDirMenu is string = "C:\Users\"+NoSpace(Usuario)+"\Microsoft\Windows\Start Menu\Programs"

//... continua ...
Boller
07 05 2024
Continuação
IF fDirectoryExist(sDirStartup) = True THEN

// trace(shortcutFree,
// sShortcut_Name,
// sShortcut_Command,
// sShortcut_Path,
// swsNormal,
// "" ,
// sShortcut_Path,
// sShortcut_Command)

CreateShortCut(shortcutFree,
sShortcut_Name,
sShortcut_Command,
sShortcut_Path,
swsNormal,
"" ,
sShortcut_Path,
sShortcut_Command)

IF fFileExist(sShortcut_Path+"tarifador.lnk") = True THEN
link is string = sShortcut_Path+"tarifador.lnk"
Info("ok",link,sDirStartup)
fCopyFile(link,sDirMenu,frConfirm)
fCopyFile(link,sDirStartup,frConfirm)
END

END

END

END
Boller
07 05 2024

Última modificación: 25/03/2025

Señalar un error o enviar una sugerencia | Ayuda local