Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
526 views
in Technique[技术] by (71.8m points)

wix - Windows application registry settings and guidelines

As I have been learning WiX to write an installer, I've learned a lot from documentation and tutorials how to setup a program during install and set or read registry values. However, the registry settings in said documentation and tutorials is done without explanation for what the requirements are for such settings.

As a specific example, I have a WiX installer for a simple application with InstallScope set to perMachine. I wanted to add a "registered user" dialog to my WiX installer. I found an example which allows the user to enter their name, organization, and a registration key. These are set to the WiX pre-defined properties: USERNAME, COMPANYNAME, and PIDKEY, respectively. When these are validated, under the hood, WiX writes these out to the following registry folder:

HKLM > Software > Microsoft > Windows > CurrentVersion > Installer > UserData > S-1-5-18 > Products > {GUID} > InstallProperties

I've been doing a lot of research trying to find the answer to the following questions and have not been able to find the answers.

  1. What are the minimum requirements (or at least minimum Microsoft guidelines) for what registry entries need to be set when installing the simplest Windows application? I know that this depends somewhat whether the install is for all users (machine), or specific users, so there would be two different answers.

  2. Where are the standard locations that simple application information is supposed to be kept in the registry?

  3. In order to meet the guidelines/requirements of #1, what are the registry settings that WiX always creates under the hood without explicit XML entries to make them occur?

  4. Once certain registry items are set, as in the example given above, how does the application locate them properly using the registry API? Specifically, for example, if once installed, I want my app to be able to read the registered user information, does it literally have to know and open the entire key as shown above, or is there a Windows API call that handles part of that?

I did find some promising looking information in the MSDN, in an article entitled, Application Registration, but I'm having trouble correlating the specifics of that article with what WiX does with the registry for an install. Specifically, for example, they suggest using HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER > SOFTWARE > Microsoft > Windows > CurrentVersion > App Paths > ... but on my system (running Windows 10) that key doesn't even exist. So other apps aren't even using it. This leads back to my question #1.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Those "WiX pre-defined properties: USERNAME, COMPANYNAME, and PIDKEY" are actually Windows Installer properties with documentation here in MSDN, such as PIDKEY here:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa370826(v=vs.85).aspx

I didn't see a question related to them, but being Windows Installer properties they are intended for use during the install. The fact that username is written to the registry is an implementation detail of the documentation:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa372385(v=vs.85).aspx

stating that if it's not automatically set it will use the previously saved value.

WiX generates MSI files for install, so many of its properties and data items translate directly to something in an MSI file or a Windows Installer property. Most of the information to do with standards and best practices for Windows Installer is here:

https://msdn.microsoft.com/en-gb/library/bb204770.aspx

as "Windows Installer Best Practices" and it includes a link to the Windows Installer Logo Requirements:

https://msdn.microsoft.com/en-gb/library/aa372825.aspx

all of which talks about installation and application best practices, so this really is a "link only" answer to that part of the question because there is a lot there.

Regarding #3 you probably mean Windows Installer, not WiX. But either way it's irrelevant because it's implementation detail. There are MSI APIs - see comment below. One example: If Windows writes information about all your installer components to the registry it is unimportant because MsiEnumComponents() will enumerate all the components on the system, MsiEnumClients() will enumerate the products that own them, MsiGetComponentPath () where a component was installed, and so on.

It's not clear from your question what "registered user information" is, unless you mean USERNAME. Do you want to find out who installed the product? If so, USERNAME is not the best choice because it doesn't have to be a user account - it's just a name. In general there are APIs for everything like this that do NOT require reading the registry. MsiGetProductInfoEx () will get you product information for a particular user. MsiEnumProductsEx () will enumerate all products and which user installed them.

PIDKEY is the non-validated product id, as the docs say. It becomes the ProductID property that can be retrieved from an app using MsiGetProductInfo (..ProductCode..., "ProductID", ...) and note also you get "RegCompany" and "RegOwner" which are the others you refer to.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...