Package: registry.win

Dependencies

   with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
   with registry.sysdep; use registry.sysdep;
   with Winreg; use Winreg;

Description

This is the real implementation for registry informations stored in the windows registry. This implementation works only on windows (but maybe not on Windows 95). The package registry.factory implements a Create function, wich returns always a suitable registry implementation.

Header

package registry.win is
 

Exceptions

REGISTRY_WRONG_PARAMETER
Raised when the key which is accessed via Get has a wrong data type. Only REG_SZ for
 Get(Reg : In Out Win_Registry; Key : In R_Key;
     Val : Out Unbounded_String)
and REG_DWORD for
 Get(Reg : In Out Win_Registry;
     Key : In R_Key;Val : Out Integer)
is allowed.

Type Summary

win_registry derived from registry_type
Overridden Operations:  Close, Create, Delete_Key, Delete_Section, Get, Get, Get_Keys, Get_Sections, Is_Open, Open, Put, Put, Set_Section

Other Items:

type win_registry is new registry_type with private;

function Create(programm_name : String;s_access : sys_access) 
return win_registry;
Create a win_registry for programm_name with selected access.
programm_name : String Name of the programm. This is used as a subkey for /Software under HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE.

procedure Put(reg : in out win_registry;
key : in r_key;
val : in String
);
Store a key/value pair in the windows registry. If the key does not exists in the section, the key is created, otherwise the old value of the key is overwritten. The value is from type String (or REG_SZ in the windows registry). The key/value pair is called value in the windows registry API documentation. The keys in the windows registry API conforms to sections within my ada registry API.
reg : win_registry a with Create initialized handle of the registry
key : r_key The key name.
val : String The string value for the key.

procedure Put(reg : in out win_registry;
key : in r_key;
val : in Integer
);
Store a key/value pair in the windows registry. If the key does not exists in the section, the key is created, otherwise the old value of the key is overwritten. The value is from type String.
reg : file_registry a with Create initialized handle of the registry
key : r_key The key name.
val : Integer The integer value for the key.

procedure Get(reg : in out win_registry;
key : in r_key;
val : out Unbounded_String
);
Get a value from a key. In case that the key does not exists the exception REGISTRY_NO_KEY is raised. Also if the key is of type REG_DWORD the exception REGISTRY_WRONG_PARAMETER is raised. The key/value pair is called value in the windows registry API documentation. The keys in the windows registry API conforms to sections within my ada registry API.
reg : file_registry a with Create initialized handle of the registry.
key : r_key The key name.
val : Unbounded_String Returns the value from the key.

procedure Get(reg : in out win_registry;
key : in r_key;
val : out Integer
);
Get a value from a key. In case that the key does not exists the exception REGISTRY_NO_KEY is raised. Also if the key is of type REG_SZ the exception REGISTRY_WRONG_PARAMETER is raised.

function Get_Sections(reg : in win_registry)
return sectionTable;
Get all known sections.
reg : file_registry a with Create initialized handle of the registry.
Returns : secionTable An array of r_section with all sections of this registry.

function Get_Keys(reg : in win_registry) 
return keyTable;
get all known keys for the current section. If there is no key, raise REGISTRY_NO_KEY exception

procedure Open(reg : in out win_registry );
Open access to the registry
reg : file_registry a with Create initialized handle of the registry.

procedure Close(reg: in out win_registry);
Close access to the registry
reg : file_registry a with Create initialized handle of the registry.

procedure Set_Section (reg : in out win_registry; s : in r_section);
Set a setion in the registry. If the section does not exists the section is created. A section correspondents to "keys" in the windows registry API.
reg : registry_type a with Create initialized handle of the registry.
s : r_section A section name.

function Is_Open(reg : in win_registry) return Boolean;
Check if the registry is opened;
reg : file_registry a with Create initialized handle of the registry.
Returns : boolean true if the registry is open.

procedure Delete_Key(reg : in out win_registry; key : in r_key);
Delete a key from the current section. In case that the key does not exists the exception REGISTRY_NO_KEY is raised.
reg : file_registry a with Create initialized handle of the registry.
key : r_key The key name to delete.

procedure Delete_Section(reg : in out win_registry; sec : in r_section);
Delete a complete section including all keys. The current section is set back to the empty default section. So after this command you must restore your previous default section via the Set_Section function. In case that the section does not exists the exception REGISTRY_NO_SECTION is raised. Also in case that subsections exists the exception REGISTRY_SUBSECTION_EXISTS is raised.
reg : file_registry a with Create initialized handle of the registry.
sec : r_section The section name to delete.

private

   --  Implementation-defined ...
end registry.win;