qzp001
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Text;  
  7. using System.Windows.Forms;  
  8. using System.Reflection;  
  9. namespace Assmest  
  10. {  
  11.    public partial class Form1 : Form  
  12.    {  
  13.       public Form1()  
  14.       {  
  15.          InitializeComponent();  
  16.          this.Text=string.Format(String.Format("关于 {0}", AssemblyTitle));  
  17.       }  
  18.       public string AssemblyTitle  
  19.       {  
  20.          get  
  21.          {  
  22.             // 获取此程序集上的所有 Title 属性  
  23.             object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);  
  24.             // 如果至少有一个 Title 属性  
  25.             if (attributes.Length > 0)  
  26.             {  
  27.                // 请选择第一个属性  
  28.                AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];  
  29.                // 如果该属性为非空字符串,则将其返回  
  30.                if (titleAttribute.Title != "")  
  31.                   return titleAttribute.Title;  
  32.             }  
  33.             // 如果没有 Title 属性,或者 Title 属性为一个空字符串,则返回 .exe 的名称  
  34.             return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);  
  35.          }  
  36.       }  
  37.    }  
  38. }  

其他的属性有:

 

 
  1. Assembly.GetExecutingAssembly().GetName().Version.ToString();  
  2. AssemblyDescriptionAttribute  
  3. AssemblyProductAttribute  
  4. AssemblyCopyrightAttribute  
  5. AssemblyCompanyAttribute 

 转自  http://blog.csdn.net/firetaker/article/details/5544830

分类:

技术点:

相关文章:

  • 2021-09-21
  • 2022-12-23
  • 2021-11-05
  • 2021-12-24
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
猜你喜欢
  • 2021-11-05
  • 2021-11-05
  • 2021-12-30
  • 2021-11-18
  • 2021-06-25
  • 2022-12-23
  • 2021-06-30
相关资源
相似解决方案