• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

25. Working with the System Registry > 25.2. Setting Registry Keys and Values

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 that normally must be added/updated through the Windows Control Panel’s ODBC Data Source Administrator. Example 25-4 shows how to add a key called MyDataSource to the registry.

Example 25-4. Creating a registry key
<!--- This creates a new key called MyDataSource under the ODBC.INI branch --->
<cfregistry action="Set"
          branch="HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI"
          type="Key" entry="MyDataSource">
 
<!--- Query the branch so that we can show it was added --->            
<cfregistry action="GatAll"
          branch="HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI"
          name="GetDSNs" type="Any" sort="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="GetDSNs">
<tr>
  <td>#Entry#</td><td>#Type#</td><td>#Value#</td>
</tr>
</cfoutput>
</table>

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint