C# - 버전, 제품명, 카피라이트, 회사명


About 화면을 만들다 나온 코드들입니다.
버전, 제품명, 카피라이트, 회사명을 가져오는 예제이구요..
using System.Reflection; 을 추가하셔야 합니다.

string m_version;
string m_product;
string m_copyright;
string m_company;

// version
m_version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

// Copyright
Type attType = typeof(AssemblyCopyrightAttribute);
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(attType, false);
if (attributes.Length != 0)
{
    AssemblyCopyrightAttribute att = (AssemblyCopyrightAttribute)attributes[0];
    m_copyright = att.Copyright;
}
else
{
    m_copyright = string.Empty;
}

// Company
attType = typeof(AssemblyCompanyAttribute);
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(attType, false);
if (attributes.Length != 0)
{
    AssemblyCompanyAttribute att = (AssemblyCompanyAttribute)attributes[0];
    m_company = att.Company;
}
else
{
    m_company = String.Empty;
}

// Product
attType = typeof(AssemblyProductAttribute);
attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(attType, false);
if (attributes.Length != 0)
{
    AssemblyProductAttribute att = (AssemblyProductAttribute)attributes[0];
    m_product = att.Product;
}
else
{
    m_product = String.Empty;
}

광고

댓글 남기기