I’m developing application that require send shortcut to desktop operation. I found only one way to implement it:
var shell = new IWshRuntimeLibrary.WshShell();
var shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(linkFileName);
shortcut.TargetPath = Application.ExecutablePath;
shortcut.WorkingDirectory = Application.StartupPath;
shortcut.Save();
It’s working coreect, but Interop.IWshRuntimeLibrary.dll required.
My application require deployment throught one small exe file, I can’t include any other files into package.
Is where a way to call COM without interop dll?
Yes you can create a COM object in .NET without an interop library. As long as they COM object implements IDispatch (which WScript.Shell does) you can call methods and properties on it easily.
If you are using .NET 4, the dynamic type makes this very easy. If not you’ll have to use Reflection to call the methods, which will work but isn’t nearly as pretty.
.NET 4 with dynamic
.NET 3.5 or earlier with Reflection