The interop assembly from msi.dll is unreliable, and I think
that's
because it was never really intended to be used that way and
anyway a)
There are plenty of Win32 Msi APIs to P/Invoke and b)
There's an
automation model for late binders.
The P/Invoke equivalent APIs are MsiEnumComponents to return
a list of
component guids, and then MsiEnumClients passing in each
component guid
to get a list of ProductCode guids, the products that use
them.
MsiGetComponentPath (Product guid, component guid, ..)
returns the path
to the item, MsiGetProductInfo (product guid,
INSTALLPROPERTY_INSTALLEDPRODUCTNAME....) will return the
product name.
C# wrappers here - scroll down.
http://i
nstallsite.org/pages/en/msi/tips.htm
Phil Wilson
-----Original Message-----
From: Discussion of development on the .NET platform using
any managed
language [mailto OTNET-CL
R DISCUSS.DEVELOP.COM] On Behalf Of Vince P
Sent: Monday, September 18, 2006 8:10 PM
To: DOTNET-CLR DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CLR] Assembly Cache
I'm wondering.. how do I create the installer object in C#.
I browsed
through the interop assembly that was created from the
msi.dll but I
don't see any actual classes, only interfaces.
-----Original Message-----
From: Discussion of development on the .NET platform using
any managed
language [mailto OTNET-CL
R DISCUSS.DEVELOP.COM] On Behalf Of Vince P
Sent: Monday, September 18, 2006 9:57 PM
To: DOTNET-CLR DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CLR] Assembly Cache
Wow. Pretty cool. Thank you much.
-----Original Message-----
From: Discussion of development on the .NET platform using
any managed
language [mailto OTNET-CL
R DISCUSS.DEVELOP.COM] On Behalf Of Wilson,
Phil
Sent: Monday, September 18, 2006 2:51 PM
To: DOTNET-CLR DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CLR] Assembly Cache
Doh~. I take back what I said. It looks like the MSI APIs
really can
do this. I made a Visual Studio setup project that installed
an assembly
in the GAC then ran the MSI vb script below. The script
shows this
output:
C0F9CB79-8E9E-F5BB-07C3-66EF6030C1B0} is used by the
product:
Set2 and is
installed at
C:\WINDOWS\assembly\GAC_MSIL\ClassLib1\1.0.0.0__f6c8407
299d7bd9d\ClassLi
b1.dll
Where the first guid is the MSI guid for the internal
component and the
second one is the ProductCode guid for my setup (product
called Set2).
Of more interest is the fact that it does actually name the
file and its
location.
This lists ALL the MSI-installed components on the system
and their
owner products so it's a sledgehammer approach, but in the
situation
where you don't know who might have installed the file
it's pretty much
all you can do.
Option Explicit
Public installer, fullmsg, comp, a, prod, fso, pname, ploc,
pid, psorce
Set fso =
CreateObject("Scripting.FileSystemObject")
Set a = fso.CreateTextFile("comps.txt", True)
' Connect to Windows Installer object
Set installer =
CreateObject("WindowsInstaller.Installer")
a.writeline ("MSI Components")
on error resume next
For Each comp In installer.components
a.writeline (comp & " is used by the
product:")
for each prod in Installer.ComponentClients (comp)
pid = installer.componentpath (prod, comp)
pname = installer.productinfo (prod,
"InstalledProductName")
a.Writeline (" " & pname &
" " & prod & " and is installed at
" & pid)
Next
Next
Phil Wilson
-----Original Message-----
From: Discussion of development on the .NET platform using
any managed
language [mailto OTNET-CL
R DISCUSS.DEVELOP.COM] On Behalf Of Mike
Woodring
Sent: Friday, September 15, 2006 12:22 PM
To: DOTNET-CLR DISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CLR] Assembly Cache
> It's all Microsoft's code. Windows Installer uses
the content of
> MsiAssembly and MsiAssemblyName tables in an MSI file
and calls fusion
> to get them installed in the GAC (not by using
gacutil). That's the
> interface that apparently doesn't provide any
mechanism to say "it was
> installed by this product". Gacutil /lr reports
no more than
> IInstallReferenceItem::GetReference() returns in
> LPFUSION_INSTALL_REFERENCE, which says nothing more
than "MSI
> installed this".
I'm not familiar with what the MSI-based installer does or
doesn't allow
you to input. I was assuming (apparently incorrectly that the
installer approach allowed you to mimic the gacutil /i
approach; as in
(w/o newlines):
gacutil /i foo.dll /r FILEPATH "c:\Program
Files\Acme\foo.dll" "Foo
library installed by Acme Corp"
The description at the end is just an arbitrary string
that's stored and
then returned by gacutil /lr. I assumed MSI based
installers could be
configured to input that description.
Seems silly that the MSI installer infrastructure doesn't
support that.
Pretty useless of them to just hard code "MSI
installed this". Or is
that just the default setting for vs.net-generated msi
installers (but
one that can still be tweaked by the aware programmer)?
-Mike
Bear Canyon Consulting LLC
http://www.bearcanyon.com
a>
http://www.pluralsigh
t.com/mike
===================================
This list is hosted by DevelopMentor(r) http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor. http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor. http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentor(r) http://www.develop.com
View archives and manage your subscription(s) at
http://discuss.develop.com
===================================
This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|