Vel*_*uis 24 .net clickonce smartclient
我在一些ClickOnce帖子中看到,ClickOnce不允许您为应用程序创建桌面图标.有没有办法解决?
Fry*_*ard 13
似乎有一种方法可以在ClickOnce桌面上放置一个图标.
Tim*_*imo 13
在Visual Studio 2005中,ClickOnce无法创建桌面图标,但现在可以在Visual Studio 2008 SP1中使用.在Visual Studio 2005中,您可以使用以下代码在应用程序启动时为您创建桌面图标.
我已经在几个项目中使用了这个代码几个月了,没有任何问题.我必须说我的所有应用程序都已在受控环境中通过Intranet部署.此外,卸载应用程序时不会删除该图标.此代码创建ClickOnce创建的开始菜单上快捷方式的快捷方式.
private void CreateDesktopIcon()
{
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
if (ad.IsFirstRun)
{
Assembly assembly = Assembly.GetEntryAssembly();
string company = string.Empty;
string description = string.Empty;
if (Attribute.IsDefined(assembly, typeof(AssemblyCompanyAttribute)))
{
AssemblyCompanyAttribute ascompany =
(AssemblyCompanyAttribute)Attribute.GetCustomAttribute(
assembly, typeof(AssemblyCompanyAttribute));
company = ascompany.Company;
}
if (Attribute.IsDefined(assembly, typeof(AssemblyDescriptionAttribute)))
{
AssemblyDescriptionAttribute asdescription =
(AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(
assembly, typeof(AssemblyDescriptionAttribute));
description = asdescription.Description;
}
if (!string.IsNullOrEmpty(company))
{
string desktopPath = string.Empty;
desktopPath = string.Concat(
Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
"\\",
description,
".appref-ms");
string shortcutName = string.Empty;
shortcutName = string.Concat(
Environment.GetFolderPath(Environment.SpecialFolder.Programs),
"\\",
company,
"\\",
description,
".appref-ms");
System.IO.File.Copy(shortcutName, desktopPath, true);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15660 次 |
| 最近记录: |