喜气羊羊

羊羊其实是条鱼|每天学习一点点|每天进步一点点

  PHP博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  68 随笔 :: 0 文章 :: 63 评论 :: 0 Trackbacks
首先要添加对 Windows Script Host Object Model的引用

然后使用
1 using IWshRuntimeLibrary;

添加代码:
 1             WshShell shell = new WshShell();
 2 
 3             string desktopShortCutPath = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\测试.lnk";
 4 
 5             desktopShortCutPath = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\程序\\ddd\\dadfd.lnk";
 6 
 7             //程序菜单用
 8             string ddd = Path.GetDirectoryName(desktopShortCutPath);
 9             if (!Directory.Exists(ddd))
10             {
11                 Directory.CreateDirectory(ddd);
12             }
13 
14             IWshShortcut sc = (IWshShortcut)shell.CreateShortcut(desktopShortCutPath);
15             sc.TargetPath = Application.StartupPath + "\\ShortCut.exe";
16             sc.Description = "测试啦";
17             sc.Save();

posted on 2008-08-31 02:27 young40 阅读(911) 评论(0)  编辑 收藏 引用 网摘 所属分类: .Net[C#]

只有注册用户登录后才能发表评论。
网站导航: