Reg_Create_Key
Obsolete
This command is obsolete. Use the cRegistry class for accessing the Windows Registry in DataFlex.
Purpose
To create a registry key named sNewKeyName, where sNewKeyName is a pathname of a registry key.
Syntax
Reg_Create_Key
sNewKeyName
TO
hKey
What It Does
Reg_Create_Key creates a registry key beneath the current registry root node. Registry keys are the principal means of storing application and system configuration information in Windows. You may access the contents of a registry key by using Get_Profile_String or Get_Profile_Dword. Unlike Set_Profile_String and Set_Profile_Dword (which also create keys), this command does not allow you to create a value within a key.
sNewKeyName must be a fully qualified key name, not including the root node name.
For example, the fully qualified path name to the VDF7 root is:
Software\Data Access Corporation\DataFlex\7
hKey will return as Zero if the key cannot be constructed. Invoke the Win32 API function GetLastError to get the error code.
Example
Procedure OnClick
End_Procedure
Object oCurrentConfigRegistry Is A Array
Function CreateCurrentConfigKey String sKey Returns Integer
Handle hKey
Handle hRegRoot
String sDefaultPath
// Create a key within the HKEY_CURRENT_CONFIG tree.
// Save off current root settings for later restore.
Get_Registry_Root To hRegRoot sDefaultPath
Set_Registry_Root To HKey_Current_Config ""
Reg_Create_Key sKey To hKey
Set_Registry_Root to hRegRoot sDefaultPath
Function_Return hKey
End_Function
Procedure Test
Handle hRegKey
Move (CreateCurrentConfigKey(current_object, "System\CurrentControlSet\Control\Print\Printers\My Printer")) To hRegKey
if (hRegKey <> 0) Begin
Showln "The created key is " hRegKey
Reg_Close_Key hRegKey
End
Else
Showln "Reg_Create_Key failed!"
End_Procedure
End_Object
Notes
Reg_Create_KeyrequiresKEY_CREATE_SUB_KEYrights.- Do not forget to close the key using the
Reg_Close_Keycommand. - The key is created in the current root. To change the registry root node, use
SET_REGISTRY_ROOT. The default value isHKEY_LOCAL_MACHINE.