ツリービューとリストビューなどを備えたexplorer.exeクローンを作成しました。
.lnk ファイルのクリックを処理する必要があるため、.lnk ファイルの宛先パスが必要です。
次を使用できますWshShell Object
。
プログラムをローカルで実行したり、レジストリの内容を操作したり、ショートカットを作成したり、システム フォルダにアクセスしたりする場合は、いつでも WshShell オブジェクトを作成します。
そしてそのCreateShortcut
方法を使用します:
新しいショートカットを作成するか、既存のショートカットを開きます。
結果のWshShortcut
オブジェクトには、TargetPath
探しているプロパティが含まれています。
例:
Dim shell = CreateObject("WScript.Shell")
Dim path = shell.CreateShortcut(path_to_your_link).TargetPath
試してみます。
Public Shared Function GetLnkTarget(lnkPath As String) As String
Dim shl = New Shell32.Shell()
' Move this to class scope
lnkPath = System.IO.Path.GetFullPath(lnkPath)
Dim dir = shl.[NameSpace](System.IO.Path.GetDirectoryName(lnkPath))
Dim itm = dir.Items().Item(System.IO.Path.GetFileName(lnkPath))
Dim lnk = DirectCast(itm.GetLink, Shell32.ShellLinkObject)
Return lnk.Target.Path
End Function
COM オブジェクトを参照する必要があります。Microsoft シェル コントロールとオートメーション。