两个方式创建clickonce的桌面快捷方式.
1.第一种,在属性--发布--选项--清单.

2.第二种,手动写程序.
static void Main() { bool bCreatedNew; Mutex m = new Mutex(false, "TestClickOnceClientName", out bCreatedNew); if (bCreatedNew) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); FrmLogin fLogin = new FrmLogin(); if (DialogResult.OK != fLogin.ShowDialog()) { return; } FrmMain fe = new FrmMain(); fe.ShowDialog(); } CreateDesktopShortCut(); } private static void CreateDesktopShortCut() { string path = System.Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); if (!path.EndsWith("\\")) { path += "\\"; } path += @"Programs\Microsoft"; if (System.IO.Directory.Exists(path)) { string desktop = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); if (!desktop.EndsWith("\\")) { desktop += "\\"; } foreach (String file in System.IO.Directory.GetFiles(path)) { System.IO.FileInfo fi = new System.IO.FileInfo(file); if (!System.IO.File.Exists(desktop + fi.Name)) { fi.CopyTo(desktop + fi.Name); } } } }
浙公网安备 33010602011771号