C#不引用IWshRuntimeLibrary获取快捷方式目标位置

private static readonly Guid CLSID_WshShell = new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8");
private static string GetShortCutTarget(string lnk) {
if (System.IO.File.Exists(lnk)) {
dynamic objWshShell = null, objShortcut = null;
try {
objWshShell = Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_WshShell));
objShortcut = objWshShell.CreateShortcut(lnk);
return objShortcut.TargetPath;
}
finally {
Marshal.ReleaseComObject(objShortcut);
Marshal.ReleaseComObject(objWshShell);
}
}
return null;
}// 获取快捷方式目标路径

C#不引用IWshRuntimeLibrary获取快捷方式目标位置

上一篇:WPF中TextBox在.NET 4.5无法输入浮点数


下一篇:Windows自动备份(每天、每月最后一天、每个周日),自动清除备份命令