Thanks Rob I tested this quickly with the code snippet below and it works great:
Type t = Type.GetTypeFromProgID("WindowsInstaller.Installer"); Installer i = (Installer)Activator.CreateInstance(t); Database d = i.OpenDatabase(@"C:\Test\Test.msi", MsiOpenDatabaseMode.msiOpenDatabaseModeReadOnly); View v = d.OpenView("SELECT * FROM Property WHERE Property = 'ProductCode'"); v.Execute(null); Record r = v.Fetch(); string version = r.get_StringData(2); On Thu, Jul 22, 2010 at 10:40 PM, Rob Mensching <r...@robmensching.com>wrote: > How about: SELECT `Value` FROM `Property` WHERE "Property"="ProductCode" > > I don't think you want ::MsiGetProductInfoFromScript(). > > On Thu, Jul 22, 2010 at 4:42 PM, Jacques Eloff <repst...@gmail.com> wrote: > > > Hi > > > > I'm trying to extract the Product code from an MSI using C# (this is for > a > > custom msbuild task I'm writing). > > > > I'm using the following definition for P/Invoke > > > > > > [DllImport("msi.dll", CharSet = CharSet.Unicode)] > > > > static extern Int32 MsiGetProductInfoFromScript(string scriptFile, > > StringBuilder product, ref ushort langId, ref uint version, > > StringBuildername, > > ref uint nameSize, StringBuilder package, ref uint packageSize); > > I keep getting a return code of 1603. Everything looks OK, but I'm > starting > > to suspect that the script file I'm passing is causing a problem, > > > > ushort langId = 0; > > > > uint version = 0; > > > > uint packageSize = 10; > > > > uint nameSize = 40; > > > > StringBuilder product = new StringBuilder(40); > > > > StringBuilder package = new StringBuilder(40); > > > > StringBuilder name = new StringBuilder(100); > > > > int e = MsiGetProductInfoFromScript(@"C:\Test\Test.msi", product, > > reflangId, > > ref version, name, ref nameSize, package, ref packageSize); > > > > Am I even calling the correct method? The only other option I can think > of > > is to open the DB and go through the whole SELECT * FROM Property and > then > > extract the product code from the returned view. > > > > Thanks, > > Jacques > > > > > ------------------------------------------------------------------------------ > > This SF.net email is sponsored by Sprint > > What will you do first with EVO, the first 4G phone? > > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > > _______________________________________________ > > WiX-users mailing list > > WiX-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wix-users > > > > > > > -- > virtually, Rob Mensching - > http://RobMensching.com<http://robmensching.com/>LLC > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > WiX-users mailing list > WiX-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wix-users > ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users