일부 ClickOnce 게시물에서 ClickOnce가 응용 프로그램의 바탕 화면 아이콘을 만들 수 없다고 읽었습니다. 이 주위에 어떤 방법이 있습니까?ClickOnce 응용 프로그램의 바탕 화면 아이콘을 만들 수 있습니까?
21
A
답변
12
, ClickOnce는 바탕 화면 아이콘을 만들 수있는 능력을 가지고 있지 않지만, 지금은 비주얼 스튜디오 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);
}
}
}
}
0
데스크톱 아이콘은 .application
파일의 바로 가기 일 수 있습니다. 응용 프로그램이 수행하는 첫 번째 작업 중 하나로 설치하십시오.
11
ClickOnce의 바탕 화면에 아이콘을 배치하는 방법이있는 것처럼 보입니다.
비주얼 스튜디오 2008 SP 1- 업그레이드 및 프로젝트 속성 윈도우의 게시 섹션의 옵션 페이지에서 데스크탑 확인란에 아이콘이 배치됩니다.
- 두 번째 옵션은 응용 프로그램의 첫 번째 실행시 바로 가기를 바탕 화면에 복사하는 코드를 응용 프로그램에 추가하는 것입니다. 블로그 게시물 How to add Desktop Shortcut to ClickOnce Deployment Application을 참조하십시오. 2005 비주얼 스튜디오 에서
코드를 복사하려면 최소한 작성자를 참조해야합니다. http://geekswithblogs.net/murraybgordon/archive/2006/10/04/ 93203.aspx – cgreeno