WSH
. , :
public void CreateLink(string shortcutFullPath, string target)
{
WshShell wshShell = new WshShell();
IWshRuntimeLibrary.IWshShortcut newShortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(shortcutFullPath);
newShortcut.TargetPath = target;
newShortcut.Save();
}
, .
. , Windows Script Object Object Model COM .
Shell32
, , :
public void ChangeLinkTarget(string shortcutFullPath, string newTarget)
{
Shell32.Shell shell = new Shell32.Shell();
Shell32.Folder folder = shell.NameSpace(Path.GetDirectoryName(shortcutFullPath));
Shell32.FolderItem folderItem = folder.Items().Item(Path.GetFileName(shortcutFullPath));
Shell32.ShellLinkObject currentLink = (Shell32.ShellLinkObject)folderItem.GetLink;
currentLink.Path = newTarget;
currentLink.Save();
}
, , , .
: , #, ++/CLI. - ++/CLI, .