The .NET way to create shortcuts (ShellLink)
Posted
Sat, Sep 18 2004 1:19
by
bill
In a recent blog entry, Duncan pointed out a way to create a shell link (shortcut) using windows scripting host. If you ask me though, that is a pretty chunky approach as it means you have a COM wrapper for WSH, and WSH itself is just wrappers for the calls to the underlying system API. So, it’s layer upon layer upon layer. That’s good if it’s a toblerone, but not so good for efficient code.
A much cooler approach is to use the very nice .NET wrapper classes Mattias Sjögren provided a few years back. The wrappers and samples are written in both VB.NET and C#.
And the even better news is that in Whidbey, the COMImport attribute bug has been fixed so the work-arounds Mattias used in VB.NET such as Activator.CreateInstance won’t be needed.
In any case, it’s great code, grab it today (oh and avoid using WSH for this)