Creare link su Windows con VB.NET
In questo articolo vediamo come creare un link, o scorciatoia, ad un file sul desktop.
Ambiente Windows, linguaggio VB.NET.
Per farlo useremo WshShell; come prima cosa dobbiamo aggiungere un riferimento COM: Progetto -> Aggiungi riferimento a COM... -> Windows Script Host Object Mode.
Qui sotto il codice:
Imports IWshRuntimeLibrary
Module Program
Sub Main(args As String())
Dim shDesktop As Object = CObj("Desktop")
Dim shell As WshShell = New WshShell()
Dim shortcutAddress As String = CStr(shell.SpecialFolders.Item(shDesktop)) & "\canzone.lnk"
Dim shortcut As IWshShortcut = CType(shell.CreateShortcut(shortcutAddress), IWshShortcut)
shortcut.Description = "Link per canzone"
shortcut.TargetPath = "D:\TEST\canzone.mp3"
shortcut.Save()
End Sub
End Module
Enjoy!
vbnet com wshshell iwshshortcut
Commentami!