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
-
INTERVIEW QUESTIONS
by sdk0121 (0 replies)
-
Run-time error 3704 operation is not allowed the object is closed
by jimholding (0 replies)
-
Looping Problem-Still does not get any answer
by syafiq_petakom (0 replies)
-
Do someone has free barcode vb6 control?
by mark81029 (9 replies)
-
Cannot implicitly convert type 'string' to 'int'?
by XxdawnmodxX (0 replies)
VB 6 podcasts
-
CodeCast: Visual Studio LightSwitch with Beth Massi
Published 1 year ago, running time 0h46m
CodeCast Episode 104: Visual Studio LightSwitch with Beth MassiIn this episode of CodeCast, Ken Levy interviews Beth Massi, a senior program manager at Microsoft on the BizApps team who build the Visual Studio tools for Azure, Office, SharePoint, and Visual Studio LightSwitch. Beth is also a
Comments