Setting Registry Keys and Values
Besides
retrieving registry keys and values, the
CFREGISTRY
tag can also create new registry keys
as well as set and update registry values. This allows you, for
example, to store application-specific information in the system
registry as opposed to in a database. It also allows you to
add/update ODBC data sources and Verity collections that normally
must be added/updated through the ColdFusion Administrator. As a
matter of fact, this is exactly how the ColdFusion Administrator
handles these tasks behind the scenes. Example 21-4
shows how to add a key called Test
to the
registry.
Example 21-4. Creating a Registry Key
<!--- this creates a new key called Test under CurrentVersion ---> <CFREGISTRY ACTION="Set" BRANCH="HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\CurrentVersion" TYPE="Key" ENTRY="Test"> <!--- Query the CurrentVersion key so that we can show it was added ---> <CFREGISTRY ACTION="GETALL" BRANCH="HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\CurrentVersion" NAME="GetCurrent" TYPE="Any" SORT="ASC"> <H3>HKEY_LOCAL_MACHINE\Software\Allaire\ColdFusion\CurrentVersion</H3> <TABLE BORDER="1"> <TR> <TH>Entry</TH><TH>Type</TH><TH>Value</TH> </TR> <CFOUTPUT QUERY="GetCurrent"> <TR> <TD>#Entry#</TD><TD>#Type#</TD><TD>#Value#</TD> </TR> </CFOUTPUT> </TABLE>
Example 21-4 uses the CFREGISTRY
tag to create a new registry key called Test
by
setting the ACTION
attribute to
Set
. BRANCH
specifies the registry branch to create the new key under. We decide ...
Get Programming ColdFusion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.