Managing
information in the Windows registry
Functions for accessing the
Registry
PowerBuilder provides several functions you can use to manage
application settings in the Windows registry.
|
Function |
Description |
|---|---|
|
RegistryDelete |
Deletes a key or a value in a key in the Windows |
|
RegistryGet |
Gets a value from the Windows |
|
RegistryKeys |
Obtains a list of the keys that are child items |
|
RegistrySet |
Sets the value for a key and value name in the |
|
RegistryValues |
Obtains a list of named values associated with a |
For the complete information for these functions, see the PowerScript Reference.
Overriding initialization
files
You can use the ProfileString functions to obtain information from
the registry instead of from an initialization file. Create a new key
called INIFILEMAPPING at the following location:
|
1 |
HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersion |
To override the WIN.INI file, create a subkey in
INIFILEMAPPING called WIN.INI with the following value:
|
1 |
#usr:softwaremicrosoftwindowscurrentversionextensions |
The examples that follow use the registry to keep track of database
connection parameters. The connection parameters are maintained in the
registry in the MyCoMyAppdatabase branch under
HKEY_CURRENT_USERSoftware.
Reading values from the registry
The following script retrieves values for the default Transaction
object from the registry.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
RegistryGet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "dbms", sqlca.DBMS) RegistryGet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "database", sqlca.database) RegistryGet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "userid", sqlca.userid) RegistryGet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "dbpass", sqlca.dbpass) RegistryGet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "logid", sqlca.logid) RegistryGet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "logpass", sqlca.logpass) RegistryGet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & �servername", sqlca.servername) RegistryGet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "dbparm", sqlca.dbparm) |
Setting values in the registry
The following script stores the values for the Transaction object in
the registry:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
RegistrySet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "dbms", sqlca.DBMS) RegistrySet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "database", sqlca.database) RegistrySet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "userid", sqlca.userid) RegistrySet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "dbpass", sqlca.dbpass) RegistrySet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "logid", sqlca.logid) RegistrySet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "logpass", sqlca.logpass) RegistrySet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "servername", sqlca.servername) RegistrySet("HKEY_CURRENT_USERSoftwareMyCoMyAppdatabase", & "dbparm", sqlca.dbparm) |