简体   繁体   中英

How to show Product version in windows form application published by installshield

I want to show current version of my windows form application project in a window. while i publish my project using visual studio publish wizard below code meet my requirement.

    public string CurrentVersion
    {
        get
        {
            return ApplicationDeployment.IsNetworkDeployed
                   ? ApplicationDeployment.CurrentDeployment.CurrentVersion.Revision.ToString()
                   : Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString();
        }
    }

Now I want to publish my project using Installshield and creating msi project. How can I get product version when using this approach?

You could do this:

var yrversion = Application.ProductVersion;
this.label1.Text = String.Format("HRIS Version {0}", yrversion);

I already researched and put these code many times on any of my projects.

Edit:

This is where the application version comes from. 这里

And you will see the changes

像这个

Don't forget to publish it.

To get the version of an MSI file you need to know its ProductCode (from the Properties window of your setup project where I assume you set it).

The core API is the Win32 MsiGetProductInfo(), but a search reveals that this SO post is a C# example:

Reading current installed version of an application using windows api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM