SP1 でデスクトップ アイコンを作成できるとは知りませんでした。
これが私たちが行ってきた方法です(現在は「難しい方法」として知られています):
try
{
string company = string.Empty;
string product = string.Empty;
if (Attribute.IsDefined(asm, typeof(AssemblyCompanyAttribute)))
{
AssemblyCompanyAttribute asCompany = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyCompanyAttribute));
company = asCompany.Company;
}
if (Attribute.IsDefined(asm, typeof(AssemblyProductAttribute)))
{
AssemblyProductAttribute asProduct = (AssemblyProductAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyProductAttribute));
product = asProduct.Product;
}
if (!string.IsNullOrEmpty(company) && !string.IsNullOrEmpty(product))
{
string desktopPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
product + ".appref-ms");
string shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
Path.Combine(company, product + ".appref-ms"));
File.Copy(shortcutPath, desktopPath, true);
}
}
catch
{
// Shortcut could not be created
}