コード例 #1
0
ファイル: ShellLink.cs プロジェクト: gggrafff/UsbBurner
        public static void Create(
            string PathToFile, string PathToLink,
            string Arguments, string Description)
        {
            ShellLink.IShellLinkW shlLink = ShellLink.CreateShellLink();

            Marshal.ThrowExceptionForHR(shlLink.SetDescription(Description));
            Marshal.ThrowExceptionForHR(shlLink.SetPath(PathToFile));
            Marshal.ThrowExceptionForHR(shlLink.SetArguments(Arguments));

            ((System.Runtime.InteropServices.ComTypes.IPersistFile)shlLink).Save(PathToLink, false);
        }
コード例 #2
0
 private void CreateShortcut(string shortcut)
 {
     if (File.Exists(shortcut))
     {
         return;
     }
     using (var link = new ShellLink()) {
         link.Target           = _mainExecutable;
         link.Description      = _application;
         link.WorkingDirectory = Path.GetDirectoryName(Path.GetDirectoryName(_mainExecutable));
         link.Save(shortcut);
     }
 }
コード例 #3
0
        private void CreateStartMenuIcon(string path)
        {
            var startPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs");

            using (ShellLink shortcut = new ShellLink())
            {
                shortcut.Target           = Path.Combine(path, "MediaCrush.exe");
                shortcut.Description      = "MediaCrush";
                shortcut.WorkingDirectory = path;
                shortcut.DisplayMode      = ShellLink.LinkDisplayMode.edmNormal;
                shortcut.Save(Path.Combine(startPath, "MediaCrush.lnk"));
            }
        }