怎么用编程的方式得到应用程序的版本和版权呀

解决方案 »

  1.   


    /***********************************************************************
     * *文 件 名:frmAbout.cs
     * *文件编号:
     * *(c)     :华联公司GPS事业部软件开发部
     * *作    者:于海洋
     * *完成日期:
     * *功能描述:封装系统关于信息
     * *修改人员:
     * *修改日期:
     * ********************************************************************/using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Collections;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Reflection;namespace DqhlGps.HlGpsLibrary
    {
        public class AboutInfo
        {
            private string m_Title;
            /// <summary>
            /// 当前程序集标题
            /// </summary>
            public string Title
            {
                get
                {
                    return this.m_Title;
                }
            }        private string m_Description;
            /// <summary>
            /// 当前程序描述信息
            /// </summary>
            public string Description
            {
                get { return this.m_Description; }
            }        private string m_Copyright;        private string m_Version;        private string m_User;
            /// <summary>
            /// 授权用户
            /// </summary>
            public string User
            {
                set
                {
                    this.m_User = value;
                }
            }        private string m_Organization;
            /// <summary>
            /// 受权单位
            /// </summary>
            public string Organization
            {
                set
                {
                    this.m_Organization = value;
                }
            }        private Image m_Image;
            /// <summary>
            /// About主图片
            /// </summary>
            public Image Image
            {
                get
                {
                    return this.m_Image;
                }
                set
                {
                    this.m_Image = value;
                }
            }        private Icon m_Icon;
            /// <summary>
            /// 当前系统图标
            /// </summary>
            public Icon Icon
            {
                get
                {
                    return this.m_Icon;
                }
                set
                {
                    this.m_Icon = value;
                }
            }        private string m_Alarm = "警告:本计算机程序受版权法和国际条约保护。如未经授权而擅自复制" + System.Environment.NewLine + "或传播本程序(或其中任何部分),将受到严厉的民事和刑事制裁,并将" + System.Environment.NewLine + "在法律许可的最大限度内受到起诉。";
            /// <summary>
            /// 警告信息
            /// </summary>
            public string Alarm
            {
                get
                {
                    return this.m_Alarm;
                }
                set
                {
                    this.m_Alarm = value;
                }
            }        private string TEXT_DECLARE = "关于 {0}";
            /// <summary>
            /// 程序信息
            /// </summary>
            public string TEXT
            {
                get
                {
                    return String.Format(TEXT_DECLARE, this.m_Title);
                }
            }        private string PRODUCT_DECLARE = "{0}  版本  {1}" + System.Environment.NewLine + "版权所有 {2}.  保留所有权利";
            /// <summary>
            /// 产品信息
            /// </summary>
            public string PRODUCT
            {
                get
                {
                    return String.Format(PRODUCT_DECLARE, this.m_Title, this.m_Version, this.m_Copyright);
                }
            }        private string AUTHORIZATION_DECLARE = "{0}" + System.Environment.NewLine + "{1}";
            /// <summary>
            /// 授权信息
            /// </summary>
            public string Authorization
            {
                get
                {
                    return String.Format(AUTHORIZATION_DECLARE, this.m_User, this.m_Organization);
                }
            }
            private Form mMainForm;        private ArrayList mAssemblyNameVersion;
            /// <summary>
            /// 当前项目程序集信息
            /// </summary>
            public ArrayList AssemblyNameVersion
            {
                get
                {
                    return this.mAssemblyNameVersion;
                }
            }        public AboutInfo(Form MainForm)
            {
                this.mMainForm = MainForm;
                this.Initialize();
            }        private void Initialize()
            {
                //获取当前程序集信息
                this.mAssemblyNameVersion = new ArrayList();
                foreach (AssemblyName RefAsm in Assembly.GetExecutingAssembly().GetReferencedAssemblies())
                {
                    this.mAssemblyNameVersion.Add(new string[] { RefAsm.Name, RefAsm.Version.ToString() });
                }            //从MainForm所在项目的AssemblyInfo.vb文件中取有关项目信息
                Type type = this.mMainForm.GetType();            //程序标题
                this.m_Title = ((AssemblyTitleAttribute)(type.Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false)[0])).Title;
                //程序描述信息
                this.m_Description = ((AssemblyDescriptionAttribute)(type.Assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false)[0])).Description;
                //程序版权信息
                this.m_Copyright = ((AssemblyCopyrightAttribute)(type.Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0])).Copyright;
                //版本信息
                this.m_Version = type.Assembly.GetName().Version.ToString();
                //授权信息如是注册形式请按具体情况读取
                this.m_User = System.Environment.UserName;
                this.m_Organization = System.Environment.MachineName;
            }
        }
    }不知道你要的是不是这个