what happens in the registry when installing with

2019-06-13 15:31发布

问题:

When installing a program in Windows 7 (all windows versions would be awesome to know about...but Windows 7 will suffice for now) with an MSI...

-What & where are the changes made in the registry on installation and how do all of those changes relate to one another?

-How can I find ALL of the data relating to a given installation should I ever need it, do I have to go through the registry to obtain this data or is there another more efficient or more appropriate way to access the data?

回答1:

Use the MSI API, such as the MsiGetProductInfoEx function. The registry data is mostly undocumented because it's an implementation detail, as Hans mentions.



回答2:

I've been playing with the registry and installations to see what I can come up with. If anyone can elaborate further on my answer or make any corrections, it would be greatly appreciated as this answer only comes from observation and not from any official source. I've made some tables describing what I've found as seen in the image below. Also, for accessing the information needed (IE, the ProductName or ProductCode properties of an MSI) I've come across WIX (http://wixtoolset.org/) and am using Micrsoft.Deployment.Installer.dll as well as other libraries included with WIX as they are pretty dang sweet.

I don't know the official terms for all of the keys & codes that I reference here...so don't be surprised if it seems like I made them up because of what they seem to designate, because I did.

Update: I just found some more useful info in the MSI docs that might be appreciated here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa372105(v=vs.85).aspx



回答3:

Using MsiGetProductInfoEx (and possibly MsiEnumProductsEx) is the recommended programmatic method to get information about installed products. Using this approach, you could then compare changes to the ProductCode, ProductVersion, and package code (i.e. Revision Number Summary property) values. A small update to the application however could leave the ProductCode and ProductVersion unchanged. A typical small update changes only one or two files or a registry key, and in this case the package code should also be changed. However, a product shipped with a language transform might have the same package code as the product without the tranform.

If you are developing your own Windows Installer package that needs to determine whether the user has already installed a version of the application, you can use the Windows Installer service to search for a specific file or directory during your application's installation. This approach requires populating the appropriate tables in the Windows installer database and the msi should run the AppSearch Action. This method is describe in Microsoft's Windows Installer documentation published here:

Searching for Existing Applications, Files, Registry Entries or .ini File Entries