Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 844037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:13:32+00:00 2026-05-15T06:13:32+00:00

To let people know what version of the program they are using, i want

  • 0

To let people know what version of the program they are using, i want to show the productversion in the title of the window. I can do that manually, but i want this to be dynamic, so i don’t have to change both items everytime the version changes.

Is this possible doing this in code behind without messing with the installer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:13:32+00:00Added an answer on May 15, 2026 at 6:13 am

    You can retrieve the version from the AssemblyName.Version property using the following code:

    Version version = Assembly.GetExecutingAssembly().GetName().Version;
    
    this.Text = "My Cool Product - Version " + version;
    
    // or with a fancier formatting
    this.Text = string.Format("My Cool Product - Version {0}.{1}.{2} Revision {3}", 
        version.Major, version.Minor, version.Build, version.Revision);
    

    Update (after comment):

    You can also read the version of the setup from the MSI information stored in the Registry. This is best done based on the UpgradeCode specified by your setup as the UpgradeCode should not change between versions. The following sample program demonstrates how to get the installed version(s)1 belonging to a specific UpgradeCode:

    using System;
    using System.Collections.Generic;
    using System.Runtime.InteropServices;
    using System.Text;
    
    class Program
    {
        [DllImport("msi.dll", CharSet = CharSet.Unicode)]
        static extern Int32 MsiGetProductInfo(string product, string property, 
            [Out] StringBuilder valueBuf, ref Int32 len);
    
        [DllImport("msi.dll", CharSet = CharSet.Auto, SetLastError = true)]
        static extern Int32 MsiEnumRelatedProducts(string strUpgradeCode, 
            int reserved, int iIndex, StringBuilder sbProductCode);
    
        static void Main(string[] args)
        {
            List<string> installedVersions = 
                GetInstalledVersions("{169C1A82-2A82-490B-8A9A-7AB7E4C7DEFE}");
    
            foreach (var item in installedVersions)
            {
                Console.WriteLine(item);
            }
        }
    
        static List<string> GetInstalledVersions(string upgradeCode)
        {
            List<string> result = new List<string>();
            StringBuilder sbProductCode = new StringBuilder(39);
            int iIdx = 0;
            while (
                0 == MsiEnumRelatedProducts(upgradeCode, 0, iIdx++, sbProductCode))
            {
                Int32 len = 512;
                StringBuilder sbVersion = new StringBuilder(len);
    
                MsiGetProductInfo(sbProductCode.ToString(), 
                    "VersionString", sbVersion, ref len);
    
                result.Add(sbVersion.ToString());
            }
            return result;
        }
    }
    

    1Note that there might be several versions of one product be installed in parallel. In that rare case you would get a list with all installed versions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an app that works in ios3 (3.0 - 3.1.3), but they've deprecated
Our SCM is Subversion. And I don't know how to handle this scenario. Let's
I know its a not a new concept that my site is perfect on
Before anything, let me first clarify that the below thoughts are purely my personal
Assume I have a CI app that does the following: Allow users to log
Howdie stackoverflow people! So I've been doing some digging regarding these NoSQL databases, MongoDB,
Hello Fellow Computer People! Anyone willing to help will have my gratitude ;) Just
First of all, I know there are excellent implementations (Qt, Boost, cpp-event, etc.), but
We have 2 systems at work that we pay for and we don't use
As i choose Wordpress for my CMS, and my client love it... i like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.