User's Guide: preTools Suite for Windows

Getting Started


Component Auto-Detection

The entries under the detect section of the configuration file are used to locate build components. Each component has two sub-elements:

registry_path is the complete path to a key in the Windows registry. Each registry_path begins with the name of a "top-level" key. The following abbreviations are used for the names of these "top-level" keys: The "top-level" key is followed by all of the subkeys that make up the complete registry path. For example, the registry_path for Visual C++ Version 8.0 is:

The second sub-element of a component entry is the registry_value. Underneath a key the registry associates "names" and "values". Several types of values can be associated with a name, REG_DWORD for a 32-bit number, REG_BINARY for a free form binary value, REG_SZ for a Unicode nul terminated string, etc. preTools assume a REG_SZ type for registry_value because the value will hold the path in which the component was installed. For Visual C++ 8.0, the value name "ProductDir" holds the path string where Visual C++ is installed (a typical value for "ProductDir" has the path "C:\Program Files\Microsoft Visual Studio 8\VC\").

Putting it all together, the complete detect section entry for Visual C++ 8.0 looks like this:

   <component name="MSVC80">

Finding a component's registry_path

You may be wondering how to go about finding a component's registry_path. Unfortunately, there is no standard key that all software uses to record its installation directory. These keys need to be determined on a case-by-case basis. Generally, a component will place its keys under "HKCU\Software\Company\Product" or "HKLM\Software\Company\Product". The table below shows some samples:

Component registry_path registry_value
Visual C++ 8.0 "HKLM\Software\Microsoft\VisualStudio\8.0\Setup\VC" "ProductDir"
Visual C++ 6.0 "HKLM\Software\Microsoft\Devstudio\6.0\Products\Microsoft Visual C++" "ProductDir"
DDK 3790
"HKLM\Software\Microsoft\WINDDK\3790" "SFNDirectory"
WDK 5384
"HKLM\Software\Microsoft\WINDDK\5384\Setup" "BUILD"

Detecting a component that doesn't have a registry_path

Not all components create registry keys or a key that identifies the installation directory. In these cases, you must create your own key for the component. These keys are added under a common node which is used by all preTools:

To illustrate how to manually create registry entries, wxWidgets, the cross-platform C++ GUI library will be used as an example. wxWidgets does create registry entries for uninstalling the library using the Inno Setup program. It also creates an environment variable, WXWIN which points to its base installation directory. However, we will create a registry_path and registry_value to point to its installation location:
  registry_path:"HKCU\Software\preTools\Components\wxWidgets 2.6.3"
  registry_value:"Install Dir" 

The string value assigned to "Install Dir" is the directory where wxWidgets was installed, e.g. "D:\wxWidgets-2.6.3". Putting it all together, the complete detect entry for wxWidgets 2.6.3 looks like this:
   <component name="WXWIDGETS-2.6.3">>
          HKCU\Software\preTools\Components\wxWidgets 2.6.3
      <registry_value>Install Dir</registry_value>
Note that this detect entry will not be guaranteed to be valid on other systems.

Scanning a local system for installed components

When you execute preMake or preBuild with the -detect command line option, each entry in the detect section is tested. First, the registry is queried for the registry_path to see if it exists, if not then 'not found' is reported for the component. If the registry_path exists, then the registry_value is queried for its value. If the registry_value does not exist, then 'not defined' is reported for the component. Finally, if both registry_path and registry_value exist, then the component is reported as 'found'. This doesn't mean that the specified installation directory has been checked for the existence of the component, it only means that valid and complete registry entries are present.

The 'not defined' state is useful, if you use a REG file to create custom entries under "HKCU\Software\preTools\Components". This allows you to leave the location unspecified, so that you can use the registry editor to add it manually.