ClickOnce 创建桌面快捷方式

  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);
}
}
}
}

(在Program中)

上一篇:Linux/UNIX编程:使用C语言实现简单的 ls 命令


下一篇:JSP网站开发基础总结《六》