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 3939394
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:17:42+00:00 2026-05-20T00:17:42+00:00

We’re making a custom boostrapper / external UI for our installation. We want to

  • 0

We’re making a custom boostrapper / external UI for our installation.

We want to provide a “Custom Installation” dialog (like in MSI) to allow the user to choose feature(s) they want to install or remove.

Currently, we are able to read the features (and other feature details like description) from the MSI database itself (by running an SQL query on the Feature table).

However, we also want to display the cost of installing a feature. Windows Installer “Custom Installation” dialog is capable of doing this.

I think we can mimic the behavior by doing the following:

  1. Pick a Feature that you want to get the cost
  2. Using the FeatureComponents table, get the Component associated with the feature from 1
  3. Using the File table, add the FileSize of the files associated with the component identified in 2
  4. The sum from 3 is the cost of the feature installation

Question:

  1. Is there an API (either from DTF or MSI.DLL) that we can use to get the cost of a feature PRIOR to installation? (There is a FeatureInfo.GetCost method in DTF but you can’t use that directly. The product must be installed first before you can call FeatureInfo.GetCost from ProductInstallation)
  2. If there is no API, is the procedure given above appropriate or correct to calculate the cost of a feature installation?

Thanks! 🙂

UPDATE # 1

I think there’s a way to get the cost of a feature installation through the API even PRIOR to starting installation. Here’s how I did it:

Installer.SetInternalUI(InstallUIOptions.Silent);

Session s = Installer.OpenPackage(@"C:\a.msi", false);

foreach (FeatureInfo info in s.Features)
{
    MessageBox.Show(info.Name);
    MessageBox.Show(info.GetCost(false, false, InstallState.Unknown).ToString());
}
s.Close();

calling info.name successfully returns the name of the feature. However, calling info.GetCost will return an InvalidHandlerException with a message: “selection manager not initialized”.

Here’s where I’m currently at.

Update #2:

I was getting the InvalidHandlerException because I am not invoking the needed file costing routines before I call info.GetCost. Here’s my modified code:

  Installer.SetInternalUI(InstallUIOptions.Silent);

  Session s = Installer.OpenPackage(@"C:\1.msi", false);
  s["ROOTDRIVE"] = @"C:\";
  s.DoAction("CostInitialize");
  s.DoAction("FileCost");
  s.DoAction("CostFinalize");

  foreach (FeatureInfo info in s.Features)
  {
       long cost = info.GetCost(false, false, InstallState.Local);
       MessageBox.Show(info.Title + " " + cost);
  }
  s.Close();

I am no longer getting the InvalidHandlerException but all file cost being returned is -1099511627776.

  • 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-20T00:17:43+00:00Added an answer on May 20, 2026 at 12:17 am

    Yes, there is an API. You need to get an MSI Session by calling OpenPackage. By doing so, you will have access to the Feature list which will give you access to the GetCost method.

    1 Gotcha: You need to perform 4 standard actions before calculating the cost: CostInitialize, FileCost, CostFinalize and InstallValidate.

        Installer.SetInternalUI(InstallUIOptions.Silent);
    
        Session s = Installer.OpenPackage(@"C:\1.msi", false);
        s.DoAction("CostInitialize");
        s.DoAction("FileCost");
        s.DoAction("CostFinalize");
        s.DoAction("InstallValidate");
    
        foreach (FeatureInfo info in s.Features)
        {
            long cost = info.GetCost(false, false, InstallState.Local);
            MessageBox.Show(info.Title + " " + cost);
        }
        s.Close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.