public void CreateDesktopLnk() { string str_FileName = System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(',')[0]; string DesktopPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop); WshShell shell = new IWshRuntimeLibrary.WshShellClass(); IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(DesktopPath + "\\" + str_FileName + ".lnk"); shortcut.TargetPath = System.Reflection.Assembly.GetExecutingAssembly().Location; shortcut.Arguments = ""; //shortcut.Description = My.Application.Info.Description; shortcut.WorkingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); //shortcut.IconLocation = @"D:\software\cmpc\zy.exe,0"; //shortcut.Hotkey = "CTRL+SHIFT+Z"; shortcut.WindowStyle = 1; shortcut.Save(); }
public bool ChangeElementType(ElementType type, ref Element element) { switch (type) { case ElementType.Heading: element.Type = type; element.IsExpanded = false; element.LevelOfSynchronization = 0; string path = element.Path; string associatedURI = element.AssociationURI; if (element.AssociationType != ElementAssociationType.FolderShortcut) { element.Path = element.ParentElement.Path + HeadingNameConverter.ConvertFromHeadingNameToFolderName(element) + System.IO.Path.DirectorySeparatorChar; element.NoteText = element.NoteText.Trim(); if (!CreateFolder(element)) { element.Type = ElementType.Note; element.AssociationURI = associatedURI; element.Path = path; //MessageBox.Show("The heading name is too long, please shorten the name and try again."); return false; } else { element.AssociationURI = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(element.Path)); if (Properties.Settings.Default.ShowOutline) { element.ShowExpander = Visibility.Visible; } return true; } } else { IWshRuntimeLibrary.WshShellClass wshShell = new IWshRuntimeLibrary.WshShellClass(); IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(element.ParentElement.Path + element.AssociationURI); if (shortcut != null) { element.Path = shortcut.TargetPath + System.IO.Path.DirectorySeparatorChar; } if (Properties.Settings.Default.ShowOutline) { element.ShowExpander = Visibility.Visible; } } break; case ElementType.Note: if (!element.IsRemoteHeading) { RemoveFolder(element); element.AssociationType = ElementAssociationType.None; element.AssociationURI = String.Empty; } else { element.AssociationType = ElementAssociationType.FolderShortcut; } element.Type = type; element.IsExpanded = false; element.LevelOfSynchronization = 0; break; }; return true; }