C# 创建快捷方式取快捷方式目标

C# 创建快捷方式取快捷方式目标,第1张

概述C# 创建快捷方式 / 取快捷方式目标

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

    using System;      using System.IO;      using System.Runtime.InteropServices;      class Program      {          static voID Main(string[] args)          {              CreateShortCut( // 创建快捷方式                      @"C:\Users\windo\Desktop\ican.lnk",@"%HOMEDRIVE%/Program files\Internet Explorer\IEXPLORE.EXE",@"http://blog.csdn.net/u012395622",@"远去的山河 沉寂  恋过的风景 如昔",AppDomain.CurrentDomain.BaseDirectory,@"%HOMEDRIVE%/Program files\Internet Explorer\IEXPLORE.EXE,0","CTRL+ALT+Z"                  );                }                public static Readonly GuID CLSID_WshShell = new GuID("72C24DD5-D70A-438B-8A42-98424B88AFB8");          public static string GetShortCutTarget(string lnk) // 取快捷方式目标          {              if (lnk != null && 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 string.Empty;          }                public static bool CreateShortCut(string lnkfilename,string targetPath,string arguments,string remark,string workingDirectory,string iconLocation,string hotKey              )          {              if (lnkfilename != null && lnkfilename.Length > 0)              {                  dynamic objWshShell = null,obJshortcut = null;                  try                  {                      objWshShell = Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_WshShell));                      obJshortcut = objWshShell.CreateShortcut(lnkfilename);                            obJshortcut.windowstyle = 1;                            obJshortcut.Hotkey = hotKey; // 热键                      obJshortcut.TargetPath = targetPath; // 目标文件                      obJshortcut.Arguments = arguments; // 参数                      obJshortcut.Description = remark; // 备注                      obJshortcut.WorkingDirectory = workingDirectory; // 起始位置                      obJshortcut.IconLocation = iconLocation; // 图标位置                            obJshortcut.Save();                            return true;                  }                  finally                  {                      Marshal.ReleaseComObject(obJshortcut);                      Marshal.ReleaseComObject(objWshShell);                  }              }              return false;          }      }  

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的C# 创建快捷方式 / 取快捷方式目标全部内容,希望文章能够帮你解决C# 创建快捷方式 / 取快捷方式目标所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1237814.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-06
下一篇2022-06-06

发表评论

登录后才能评论

评论列表(0条)

    保存