Pregunta: | 60210 - ACCESO DIRECTO EN VB6 |
Autor: | Mikel Arrasate |
Hola a todos,
Estoy intentando crear un acceso directo (*.lnk) de un archivo existente. Tengo el vb6 y no lo consigo, ¿alguien me podría ayudar? Muchísimas gracias. |
Respuesta: | Mikel Arrasate |
Hola, ya he encontrado la respuesta:
Funciona perfectamente, lo que no sé es si podré activar el "Windows Script Host Object Model" en una macro de Solidworks... 1) Open a new exe standard proyect 2) Add one CommandButton, and two Textboxes, called cmdMakeLNKFile, txtTarget and txtLnkName respectively 3) Add the reference to the Windows Script Host Object Model (file: wshom.ocx, located in your system directory) 4) Copy this code to the Declarations sections: Dim Shell As WshShell Dim Shortcut As WshShortcut 5) Add this code to your form Private Sub cmdMakeLNKFile_Click() 'initialize the object WshShell Set objShell = New WshShell 'initialize the object WshShortcut 'the complete name of the .lnk file, include full path plus the .LNK file extension Set objShortcut = objShell.CreateShortcut (txtLnkName.Text) 'the file to be called by the .lnk file, ej. "c:windowscalc.exe" objShortcut.TargetPath = txtTarget.Text '(optional) := any command line supported by the file indicated in txtTarget.Text 'objShortcut.Arguments = xxxx '(optional) : = a valid icon file : = To use the same icon of the target file, do not use the next line. 'objShortcut.IconLocation = xxxx 'Save the .lnk objShortcut.Save End Sub |