* Make-lang.in (cp/pt.o): Depend on vecprim.h.
[official-gcc.git] / gcc / ada / g-regist.ads
blob054ebb8a08bd31f4c7b4929f8aeabba24239fd10
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- G N A T . R E G I S T R Y --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2001-2005, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 -- --
31 ------------------------------------------------------------------------------
33 -- The registry is a Windows database to store key/value pair. It is used
34 -- to keep Windows operation system and applications configuration options.
35 -- The database is a hierarchal set of key and for each key a value can
36 -- be associated. This package provides high level routines to deal with
37 -- the Windows registry. For full registry API, but at a lower level of
38 -- abstraction, refer to the Win32.Winreg package provided with the
39 -- Win32Ada binding. For example this binding handle only key values of
40 -- type Standard.String.
42 -- This package is specific to the NT version of GNAT, and is not available
43 -- on any other platforms.
45 package GNAT.Registry is
47 type HKEY is private;
48 -- HKEY is a handle to a registry key, including standard registry keys:
49 -- HKEY_CLASSES_ROOT, HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER,
50 -- HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_PERFORMANCE_DATA.
52 HKEY_CLASSES_ROOT : constant HKEY;
53 HKEY_CURRENT_USER : constant HKEY;
54 HKEY_CURRENT_CONFIG : constant HKEY;
55 HKEY_LOCAL_MACHINE : constant HKEY;
56 HKEY_USERS : constant HKEY;
57 HKEY_PERFORMANCE_DATA : constant HKEY;
59 type Key_Mode is (Read_Only, Read_Write);
60 -- Access mode for the registry key
62 Registry_Error : exception;
63 -- Registry_Error is raises by all routines below if a problem occurs
64 -- (key cannot be opened, key cannot be found etc).
66 function Create_Key
67 (From_Key : HKEY;
68 Sub_Key : String;
69 Mode : Key_Mode := Read_Write) return HKEY;
70 -- Open or create a key (named Sub_Key) in the Windows registry database.
71 -- The key will be created under key From_Key. It returns the key handle.
72 -- From_Key must be a valid handle to an already opened key or one of
73 -- the standard keys identified by HKEY declarations above.
75 function Open_Key
76 (From_Key : HKEY;
77 Sub_Key : String;
78 Mode : Key_Mode := Read_Only) return HKEY;
79 -- Return a registry key handle for key named Sub_Key opened under key
80 -- From_Key. It is possible to open a key at any level in the registry
81 -- tree in a single call to Open_Key.
83 procedure Close_Key (Key : HKEY);
84 -- Close registry key handle. All resources used by Key are released
86 function Key_Exists (From_Key : HKEY; Sub_Key : String) return Boolean;
87 -- Returns True if Sub_Key is defined under From_Key in the registry
89 function Query_Value
90 (From_Key : HKEY;
91 Sub_Key : String;
92 Expand : Boolean := False) return String;
93 -- Returns the registry key's value associated with Sub_Key in From_Key
94 -- registry key. If Expand is set to True and the Sub_Key is a
95 -- REG_EXPAND_SZ the returned value will have the %name% variables
96 -- replaced by the corresponding environment variable value.
98 procedure Set_Value (From_Key : HKEY; Sub_Key : String; Value : String);
99 -- Add the pair (Sub_Key, Value) into From_Key registry key
101 procedure Delete_Key (From_Key : HKEY; Sub_Key : String);
102 -- Remove Sub_Key from the registry key From_Key
104 procedure Delete_Value (From_Key : HKEY; Sub_Key : String);
105 -- Remove the named value Sub_Key from the registry key From_Key
107 generic
108 with procedure Action
109 (Index : Positive;
110 Sub_Key : String;
111 Value : String;
112 Quit : in out Boolean);
113 procedure For_Every_Key_Value (From_Key : HKEY; Expand : Boolean := False);
114 -- Iterates over all the pairs (Sub_Key, Value) registered under
115 -- From_Key. Index will be set to 1 for the first key and will be
116 -- incremented by one in each iteration. Quit can be set to True to
117 -- stop iteration; its initial value is False.
119 -- Key value that are not of type string (i.e. not REG_SZ / REG_EXPAND_SZ)
120 -- are skipped. In this case, the iterator behaves exactly as if the key
121 -- were not present. Note that you must use the Win32.Winreg API to deal
122 -- with this case. Furthermore, if Expand is set to True and the Sub_Key
123 -- is a REG_EXPAND_SZ the returned value will have the %name% variables
124 -- replaced by the corresponding environment variable value.
126 private
128 type HKEY is mod 2 ** Integer'Size;
130 HKEY_CLASSES_ROOT : constant HKEY := 16#80000000#;
131 HKEY_CURRENT_USER : constant HKEY := 16#80000001#;
132 HKEY_LOCAL_MACHINE : constant HKEY := 16#80000002#;
133 HKEY_USERS : constant HKEY := 16#80000003#;
134 HKEY_PERFORMANCE_DATA : constant HKEY := 16#80000004#;
135 HKEY_CURRENT_CONFIG : constant HKEY := 16#80000005#;
137 end GNAT.Registry;