Skip to main content

Beyond Files

In the real life out there, you'll probably need more to do than to copy files into their final repository. To create a registry keys, include them inside a RegistryKey in the component:

<RegistryKey Id='FoobarRegInstallDir' Root='HKLM' Key='Software\Acme\Foobar 1.0' Action='createAndRemoveOnUninstall'>
  <RegistryValue Type='string' Name='InstallDir' Value='[INSTALLDIR]'/>
  <RegistryValue Type='integer' Name='Flag' Value='0'/>
</RegistryKey>

The Action attribute can be either create or createAndRemoveOnUninstall. Type can be string, integer, binary, expandable and multiString. If the Name attribute is omitted, the default key will be created.

In the case of a multiString, use one or more RegistryValue children to specify the individual strings:

<RegistryKey Id='FoobarRegInstallDir' Root='HKLM' Key='Software\Acme\Foobar 1.0' Action='createAndRemoveOnUninstall'>
  <RegistryValue Type='multiString' Name='InstallDir' Value='[TARGETDIR]'/>
  <RegistryValue Type='multiString' Name='InstallDir' Value='[INSTALLDIR]' Action='append'/>
  <RegistryValue Type='multiString' Name='InstallDir' Value='[ProgramFilesFolder] Action='append'/>
</RegistryKey>

If your application handles its own file data type, you will need to register a file association for it. Put a ProgId inside your component. FileId should refer to the Id attribute of the File element describing the file meant to handle the files of this extension:

<ProgId Id='AcmeFoobar.xyzfile' Description='Acme Foobar data file'>
  <Extension Id='xyz' ContentType='application/xyz'>
    <Verb Id='open' Command='Open' TargetFile='FileId' Argument='"%1"' />
  </Extension>
</ProgId>

To assign an icon to this file type, you have to specify where the icon should come from:

<ProgId Id='AcmeFoobar.xyzfile' Description='Acme Foobar data file' Icon='Foobar.ico'>

or, if the icon comes from an executable or resource file containing several icons, you can specify which one:

<ProgId Id='AcmeFoobar.xyzfile' Description='Acme Foobar data file' Icon='Foobar.exe' IconIndex='1'>

And finally, if you want to write an .ini file—although the registry is more in vogue these days—, this is what you need in your component. The file will always be created in the system folder, not in the installation target one:

<IniFile Id="WriteIntoIniFile" Action="addLine" Key="InstallDir" Name="Foobar.ini"
  Section="Paths" Value="[INSTALLDIR]" />

In the next lesson we'll see how to implement a user interface so that the user can get a chance to decide what and where to install.

multiString registry example does not work

I was not able to obtain working example with 'multiString'.
 
I have found how to fix it at http://stackoverflow.com/questions/3749863/how-to-add-multistring-regist...

closing quote missed

In the line

<RegistryValue Type='multiString' Name='InstallDir' Value='[ProgramFilesFolder] Action='append'/>

closing quote is missing after [ProgramFilesFolder]