locked
Aboutbox

    Question

  • I am studing Visual C++ Express IDE, and I am traying to build a new project, in which I add an AboutBox.
    I would use AssemblyInfo data to fill Aboutbox and I am translating program lines from a c# application.
    I can not translate the following line:
    object[] attributes=Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute),false);
    In particular I am not able to find the corrisponding c++ syntax for object[].
    Can you help me?
    Many thanks.
    Antonio Di Leo

    Saturday, February 21, 2009 9:57 PM

Answers

  • Doing it step by step:

      using namespace System::Reflection;
    ...
                 Assembly^ assm = Assembly::GetExecutingAssembly();
                 Type^ attype = AssemblyTitleAttribute::typeid;
                 array<Object^>^ attrs = assm->GetCustomAttributes(attype, false);
                 if (attrs->Length > 0) {
                   AssemblyTitleAttribute^ value = dynamic_cast<AssemblyTitleAttribute^>(attrs[0]);
                   String^ title = value->Title;
                   Console::WriteLine(title);
                 }


    Hans Passant.
    • Marked as answer by Wesley Yao Friday, February 27, 2009 2:40 AM
    Sunday, February 22, 2009 1:19 PM
    Moderator

All replies

  • Doing it step by step:

      using namespace System::Reflection;
    ...
                 Assembly^ assm = Assembly::GetExecutingAssembly();
                 Type^ attype = AssemblyTitleAttribute::typeid;
                 array<Object^>^ attrs = assm->GetCustomAttributes(attype, false);
                 if (attrs->Length > 0) {
                   AssemblyTitleAttribute^ value = dynamic_cast<AssemblyTitleAttribute^>(attrs[0]);
                   String^ title = value->Title;
                   Console::WriteLine(title);
                 }


    Hans Passant.
    • Marked as answer by Wesley Yao Friday, February 27, 2009 2:40 AM
    Sunday, February 22, 2009 1:19 PM
    Moderator
  • Many Thanks
    Antonio
    Sunday, February 22, 2009 3:14 PM