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:\windows\calc.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
Create a File Shortcut
By Carlos Icaza, published on 21 Apr 2002
| Filed in
You might also like...
VB 6 forum discussion
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
client/server application using activex
by beautifulheart (0 replies)
-
System Error &H8007007E. The specifed module could not be found.
by swiftsafe (5 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
Send SMS with SMPP
by mmahmoud (0 replies)
VB 6 podcasts
-
Stack Overflow Podcast: Podcast #45 – Keeping it Sharp
Published 7 years ago, running time 0h54m
Our guest this week is Eric Lippert – language architect extraordinaire and famous for all his work at Microsoft in developing their languages Eric joined Microsoft right out of college and was originally working on VB It’s time for everyone’s favorite game: Name the Worst Feature of that Microso.
Comments