ClickOnce 응용 프로그램을위한 데스크톱 아이콘을 만들 수 있습니까?
-
02-07-2019 - |
문제
ClickOnce를 사용하여 응용 프로그램을위한 데스크탑 아이콘을 만들 수없는 일부 ClickOnce 게시물에서 읽었습니다. 이 주위에 어떤 방법이 있습니까?
해결책
Visual Studio 2005에서 Clickonce 데스크탑 아이콘을 만들 수있는 기능은 없지만 이제 Visual Studio 2008 SP1에서 사용할 수 있습니다. Visual Studio 2005에서는 다음 코드를 사용하여 응용 프로그램이 시작될 때 데스크탑 아이콘을 만들 수 있습니다.
나는 몇 달 동안 몇 달 동안 여러 프로젝트를 통해이 코드를 사용하여 아무런 문제없이 사용했습니다. 제어 된 환경에서 모든 응용 프로그램이 인트라넷에 배치되었다고 말해야합니다. 또한 응용 프로그램이 제거되면 아이콘이 제거되지 않습니다. 이 코드는 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);
}
}
}
}
다른 팁
ClickOnce의 데스크탑에 아이콘을 배치하는 방법이있는 것 같습니다.
- Visual Studio 2008 SP 1로 업그레이드하면 프로젝트 속성 창의 게시 옵션 섹션 페이지에 데스크탑 확인란에 아이콘이 배치됩니다.
- 두 번째 옵션은 응용 프로그램에 코드를 추가하여 응용 프로그램의 첫 번째 실행에서 바로 가기를 데스크탑에 복사하는 코드를 추가하는 것입니다. 블로그 게시물을 참조하십시오 ClickOnce 배포 애플리케이션에 데스크탑 단축키를 추가하는 방법.
데스크탑 아이콘은 바로 가기가 될 수 있습니다 .application
파일. 응용 프로그램이 가장 먼저하는 일 중 하나로 설치하십시오.
Visual Studio 2017 및 2019에서는 다음을 수행 할 수 있습니다.
Project Properties-> 게시 -> 매니페스트로 이동하여 옵션을 선택하십시오. 데스크탑 단축키를 만듭니다
제휴하지 않습니다 StackOverflow