In un nuovo progetto, aggiungere il riferimento alla libreria COM (unmanaged) “Windows Script Host Object Model“.
Nella sezione del codice del form (Form1.vb) inserire questo esempio:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show(ReadShortcut("C:\prova2.lnk")) End Sub Public Function ReadShortcut(ByVal FilePath As String) As String If System.IO.File.Exists(FilePath) Then Dim theShell As New IWshRuntimeLibrary.WshShell() Dim theShortcut As IWshRuntimeLibrary.WshShortcut = _ theShell.CreateShortcut(FilePath) Return theShortcut.TargetPath Else Return "Il file non esiste." End If End Function
End Class