The numeric codes for the symbolics can be looked up here but I'm sure there
is a way to get the Enums for them.

http://msdn.microsoft.com/en-us/library/18d8fbe8-a967-4f1c-ae50-99ca8e491d2d(PROT.10).aspx


On Thu, Aug 25, 2011 at 4:26 PM, Anil Patel <apatel...@googlemail.com>wrote:

> Hi Peter & James,
>
> I really appreciate your help on this - thank you!!
>
> I went with the interop route and attach a sample app (if anyone is
> interested) in what I have done.
>
> Best Regards,
> Anil.
>
> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;
> using System.Runtime.InteropServices;
> namespace ConsoleApplication2
> {
>     class Program
>
>     {
>         [DllImport("msi", CharSet = CharSet.Auto)]
>         static extern int MsiGetProductCode(string component, StringBuilder
> buffer);
>
>         [DllImport("msi", CharSet = CharSet.Auto)]
>         static extern int MsiEnumFeatures(string product, uint
> featureIndex, StringBuilder featureBuffer, StringBuilder parentBuffer);
>
>         [DllImport("msi", CharSet = CharSet.Auto)]
>         static extern int MsiQueryFeatureState(string product, string
> featureBuffer);
>
>         public static string GetProductCode(string component)
>         {
>             StringBuilder productCodeStringBuilder = new
> StringBuilder(512);
>             int nRes = MsiGetProductCode(component,
> productCodeStringBuilder);
>             return productCodeStringBuilder.ToString();
>
>             //switch (MsiGetProductCode(component,
> productCodeStringBuilder))
>
>             //{
>             //    case ERROR_SUCCESS:
>             //        return productCodeStringBuilder.ToString();
>             //    // *Please* don't actually just throw an exception like
> this.
>             //    // Throw the relevent exception based on the error code
> returned.
>             //    case ERROR_BAD_CONFIGURATION:
>             //        throw new Exception("The configuration data is
> corrupt.");
>             //    case ERROR_INSTALL_FAILURE:
>             //        throw new Exception("The product code could not be
> determined.");
>             //    case ERROR_INVALID_PARAMETER:
>             //        throw new Exception("An invalid parameter was passed
> to the function.");
>             //    case ERROR_UNKNOWN_COMPONENT:
>             //        throw new Exception("The specified component is
> unknown.");
>             //    default:
>             //        throw new Exception();
>             //}
>         }
>         public static void EnumFeatures(string product)
>         {
>             StringBuilder featureBuf = new StringBuilder(256);
>             StringBuilder parentBuf = new StringBuilder(256);
>
>             for (uint i=0; ; i++)
>             {
>                 int nRes = MsiEnumFeatures(product, i, featureBuf,
> parentBuf);
>                 if (nRes != 0)
>                     break;
>
>                 int featureQCode = QueryFeatureState(product,
> featureBuf.ToString());
>
>                 Console.WriteLine(String.Format("Feature {0} ",
> featureBuf.ToString()));
>             }
>             return;
>         }
>
>         public static int QueryFeatureState(string product, string feature)
>         {
>             return MsiQueryFeatureState(product, feature);
>         }
>
>         static void Main(string[] args)
>         {
>             //pass in guid of product
>             string s =
> GetProductCode("{14CCA315-92CE-48E7-8C7C-87923F770B47}");
>             EnumFeatures(s);
>         }
>     }
> }
>
> //useful links
> http://source.winehq.org/source/include/msi.h
> http://msdn.microsoft.com/en-us/library/aa369426(v=VS.85).aspx
>
>
>
>
>
> On Thu, Aug 25, 2011 at 3:33 PM, James Johnston <johnst...@inn-soft.com>wrote:
>
>> You could always use the COM library if you're not comfortable with the C
>> API calls.  Add a COM reference to "Microsoft Windows Installer Object
>> Library" to your project...
>>
>> Installer.get_Features and Installer.get_FeatureState look like they might
>> be useful.
>>
>> -----Original Message-----
>> From: Anil Patel [mailto:apatel...@googlemail.com]
>> Sent: Thursday, August 25, 2011 11:12
>> To: General discussion for Windows Installer XML toolset.
>> Subject: Re: [WiX-users] Identifying Features that have been installed
>>
>> Hi Peter,
>>
>> Really appreciate your feedback on this.
>>
>> The MsiGetEnumsFeatues() is defined as
>>
>> UINT MsiEnumFeatures(
>>  __in   LPCTSTR szProduct,
>>  __in   DWORD iFeatureIndex,
>>  __out  LPTSTR lpFeatureBuf,
>>  __out  LPTSTR lpParentBuf
>> );
>>
>> So to get the product code, I found this code
>>
>>        [DllImport("msi", CharSet = CharSet.Auto)]
>>        static extern int MsiGetProductCode(string component, StringBuilder
>> buffer);
>>
>>        public static string GetProductCode(string component)
>>        {
>>            StringBuilder productCodeStringBuilder = new
>> StringBuilder(512);
>>            switch (MsiGetProductCode(component, productCodeStringBuilder))
>>            {
>>                case ERROR_SUCCESS:
>>                    return productCodeStringBuilder.ToString();
>>                // *Please* don't actually just throw an exception like
>> this.
>>                // Throw the relevent exception based on the error code
>> returned.
>>                case ERROR_BAD_CONFIGURATION:
>>                    throw new Exception("The configuration data is
>> corrupt.");
>>                case ERROR_INSTALL_FAILURE:
>>                    throw new Exception("The product code could not be
>> determined.");
>>                case ERROR_INVALID_PARAMETER:
>>                    throw new Exception("An invalid parameter was passed to
>> the function.");
>>                case ERROR_UNKNOWN_COMPONENT:
>>                    throw new Exception("The specified component is
>> unknown.");
>>                default:
>>                    throw new Exception();
>>            }
>>        }
>>
>> The problem is thay symbolic constants in the switch statement (eg
>> ERROR_INVALID_PARAMETER which are uints) aren't recognised so error on
>> compile.
>>
>> Do you know how I can resolve these. I'm assuming there might be an Enum
>> for
>> them but I can't locate them.
>>
>> Again any help would be appreciated.
>>
>> Regards,
>> Anil.
>>
>>
>> On Thu, Aug 25, 2011 at 11:13 AM, Peter Shirtcliffe
>> <pshirtcli...@sdl.com>wrote:
>>
>> > MsiEnumFeatures()
>> > http://msdn.microsoft.com/en-us/library/aa370098%28v=vs.85%29.aspx
>> >
>> >
>> > -----Original Message-----
>> > From: Anil Patel [mailto:apatel...@googlemail.com]
>> > Sent: 25 August 2011 11:08
>> > To: General discussion for Windows Installer XML toolset.
>> > Subject: [WiX-users] Identifying Features that have been installed
>> >
>> > Hello,
>> >
>> > I have a configuration program that is run manually by a user
>> > (following a new install or a change to an existing installation)
>> > which allows the user to configure the installed features.
>> >
>> > There is a requirement to disable the configuration of features not
>> > installed by the user.
>> >
>> > The question is, is there a way for the configuration program to
>> > identify which featues have been installed?
>> >
>> > I could record this data into the registry during the install and
>> > remove it when a feature is uninstalled but I just wondered if there
>> > was any other way of doing this.
>> >
>> > Thank you for your time.
>> >
>> >
>> > Regards,
>> > Anil.
>> >
>> > ----------------------------------------------------------------------
>> > -------
>> > -
>> > EMC VNX: the world's simplest storage, starting under $10K The only
>> > unified storage solution that offers unified management Up to 160%
>> > more powerful than alternatives and 25% more efficient.
>> > Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
>> > _______________________________________________
>> > WiX-users mailing list
>> > WiX-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/wix-users
>> > SDL PLC confidential, all rights reserved.
>> > If you are not the intended recipient of this mail SDL requests and
>> > requires that you delete it without acting upon or copying any of its
>> > contents, and we further request that you advise us.
>> > SDL PLC is a public limited company registered in England and Wales.
>> >  Registered number: 02675207.
>> > Registered address: Globe House, Clivemont Road, Maidenhead, Berkshire
>> > SL6 7DY, UK.
>> >
>> >
>> >
>> > ----------------------------------------------------------------------
>> > -------- EMC VNX: the world's simplest storage, starting under $10K
>> > The only unified storage solution that offers unified management Up to
>> > 160% more powerful than alternatives and 25% more efficient.
>> > Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
>> > _______________________________________________
>> > WiX-users mailing list
>> > WiX-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/wix-users
>> >
>>
>> ----------------------------------------------------------------------------
>> --
>> EMC VNX: the world's simplest storage, starting under $10K The only
>> unified
>> storage solution that offers unified management Up to 160% more powerful
>> than alternatives and 25% more efficient.
>> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
>> _______________________________________________
>> WiX-users mailing list
>> WiX-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wix-users
>>
>>
>>
>> ------------------------------------------------------------------------------
>> EMC VNX: the world's simplest storage, starting under $10K
>> The only unified storage solution that offers unified management
>> Up to 160% more powerful than alternatives and 25% more efficient.
>> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
>> _______________________________________________
>> WiX-users mailing list
>> WiX-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wix-users
>>
>
>
------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to