I think I’m getting closer to finding what I need, but I’m not there yet.
I found this article on Shell Links:
http://msdn2.microsoft.com/en-us/library/aa969393.aspx. Basically, it says
that what I’m trying to do is “resolve†the shell link.
Searching on “resolve shell link†led me
http://msdn2.microsoft.com/en-us/library/ms630340.aspx which contains a
Visual Basic example of the resolution process. It looks like it was written
for VB 5.0 so I’ve tried to update it to a .Net version. This is what I came
up with.
Imports Shell32
Imports Shell32.ShellSpecialFolderConstants
Module Module1
Public Sub Main()
ResolveShellLink("C:\Documents and Settings\All Users\" & _
"Start Menu\Programs\Accessories", _
"Calculator.lnk")
ResolveShellLink ("C:\Documents and Settings\All Users\Desktop", _
"System.lnk")
End Sub
Private Function ResolveShellLink(PathName As String, _
ShortcutName As String) As Boolean
Dim objShell As Shell = New Shell()
If objShell Is Nothing Then Return False
Dim objFolder As Folder = objShell.NameSpace(PathName)
If objFolder Is Nothing Then Return False
Dim objFolderItem As FolderItem = objFolder.ParseName(ShortcutName)
If objFolderItem Is Nothing Then Return False
Dim objShellLink As ShellLinkObject = _
CType(objFolderItem.GetLink(), ShellLinkObject)
If objShellLink Is Nothing Then Return False
objShellLink.Resolve(1)
Return True
End Function
End Module
After adding a reference to COM module “Microsoft Shell Controls And
Automation†I was able to compile and run this code without any errors.
Unfortunately, it didn’t run “Calculator†or the shortcut to “System†that I
had placed on my desktop. What needs to be done to get this to run the
applications in the shortcuts?