O'Reilly logo

Programming ColdFusion MX, 2nd Edition by Rob Brooks-Bilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting Registry Keys and Values

The cfregistry tag gives you two methods for retrieving keys and values from the registry. You can set the action attribute to GetAll to retrieve all the particular keys/values associated with a particular branch, or you can set action="Get" to retrieve the value associated with a specific entry.

Let’s consider a scenario where we want to look up information about any ODBC data sources set up on the same machine as ColdFusion. There is a registry branch we can access that contains this information. The branch is:

HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI

It contains a list of every ODBC data source registered on the system. Each key contains several other subkeys relating to the ODBC connection. Example 25-1 shows how to perform the registry lookup.

Example 25-1. Retrieving a list of registry keys

<cfregistry action="GetAll" branch="HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI"
            name="GetODBC" type="Key" sort="Entry Asc">
 
<h3>HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI</h3>
 
<table border="1">
<tr>
  <th>Entry</th><th>Type</th><th>Value</th>
</tr>
 
<cfoutput query="GetODBC">
<tr>
  <td>#Entry#</td><td>#Type#</td><td>#Value#</td>
</tr>
</cfoutput>
</table>

In Example 25-1, we set the action attribute of the cfregistry tag to GetAll. This action results in ColdFusion retrieving all the registry keys and values that fall under the branch specified in branch. The name attribute allows us to specify a name for the query object that holds all the information we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required