[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Setting/Obtaining Version Info in C++.Net v1.0

Posted on 2004-11-02
3
Medium Priority
?
196 Views
Last Modified: 2010-04-24
Hi,

Is there a reliable way of setting and obtaining file version info in C++.Net v1.0? I can "successfully" set the version of the file by setting the AssemblyVersionAttribute (and AssemblyFileVersionAttribute) in AssemblyInfo.cpp, but the only way I can view this is by opening the file in ILDASM - not by positioning my mouse over the file or in the properties. However, this would be fine, except I cannot get the version progammatically. I've used Application, Form, and FileVersionInfo to no avail. Is there a way to set the version so that you can get the version programmatically in VC++.Net v1.0?

Thanks,
mpf1748
0
Comment
Question by:mpf1748
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
javanic earned 1000 total points
ID: 12508024
Here's what I'm doing. Note: replace YOURASSEMBLYNAME with your own assembly's name. I've put the message box in here to show what the results are. You must then parse the resulting assembly string to get the Version=x.x.x.x value.

// You'll need these namespaces
using namespace System::Reflection; // for Assembly
using namespace System::Threading; // for Thread

// t hen in your code, do this

Assembly * myAssemblies[] = Thread::GetDomain()->GetAssemblies();
Assembly * myAssembly = 0;
for (int i = 0; i < myAssemblies->Length; i++)
{
  if (String::Compare(myAssemblies[i]->GetName()->Name, S"YOURASSEMBLYNAME") == 0)
     myAssembly = myAssemblies[i];
}
if (myAssembly != 0)
{
   MessageBox::Show(myAssembly->ToString(), S"Assembly string");
}

// now parse the myAssembly->ToString() to get the Version=x.x.x.x value.


P.S. if there's a better way, I'd like to know.
0
 
LVL 3

Author Comment

by:mpf1748
ID: 12510202
Thanks.

Not as easy as I was hoping, but it works. There is Assembly::GetExecutingAssembly() that simply returns the original assembly that is loaded if that's the assembly you want the version from. Although you still have to parse out that Version.

mpf1748
0
 
LVL 3

Author Comment

by:mpf1748
ID: 12510392
Actually that is the current current assembly, not the original executing assembly.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question