1 /* GIO - GLib Input, Output and Streaming Library 2 * 3 * Copyright (C) 2014 Руслан Ижбулатов <lrn1986@gmail.com> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General 16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 #ifndef __G_WIN32_REGISTRY_KEY_H__ 20 #define __G_WIN32_REGISTRY_KEY_H__ 21 22 #include <gio/gio.h> 23 24 #ifdef G_PLATFORM_WIN32 25 26 G_BEGIN_DECLS 27 28 #define G_TYPE_WIN32_REGISTRY_KEY (g_win32_registry_key_get_type ()) 29 #define G_WIN32_REGISTRY_KEY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_WIN32_REGISTRY_KEY, GWin32RegistryKey)) 30 #define G_WIN32_REGISTRY_KEY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_WIN32_REGISTRY_KEY, GWin32RegistryKeyClass)) 31 #define G_IS_WIN32_REGISTRY_KEY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_WIN32_REGISTRY_KEY)) 32 #define G_IS_WIN32_REGISTRY_KEY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_WIN32_REGISTRY_KEY)) 33 #define G_WIN32_REGISTRY_KEY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_WIN32_REGISTRY_KEY, GWin32RegistryKeyClass)) 34 35 typedef enum { 36 G_WIN32_REGISTRY_VALUE_NONE = 0, 37 G_WIN32_REGISTRY_VALUE_BINARY = 1, 38 G_WIN32_REGISTRY_VALUE_UINT32LE = 2, 39 G_WIN32_REGISTRY_VALUE_UINT32BE = 3, 40 #if G_BYTE_ORDER == G_BIG_ENDIAN 41 G_WIN32_REGISTRY_VALUE_UINT32 = G_WIN32_REGISTRY_VALUE_UINT32BE, 42 #else 43 G_WIN32_REGISTRY_VALUE_UINT32 = G_WIN32_REGISTRY_VALUE_UINT32LE, 44 #endif 45 G_WIN32_REGISTRY_VALUE_EXPAND_STR = 4, 46 G_WIN32_REGISTRY_VALUE_LINK = 5, 47 G_WIN32_REGISTRY_VALUE_MULTI_STR = 6, 48 G_WIN32_REGISTRY_VALUE_UINT64LE = 7, 49 #if G_BYTE_ORDER == G_LITTLE_ENDIAN 50 G_WIN32_REGISTRY_VALUE_UINT64 = G_WIN32_REGISTRY_VALUE_UINT64LE, 51 #endif 52 G_WIN32_REGISTRY_VALUE_STR = 8 53 } GWin32RegistryValueType; 54 55 typedef enum { 56 G_WIN32_REGISTRY_WATCH_NAME = 1 << 0, 57 G_WIN32_REGISTRY_WATCH_ATTRIBUTES = 1 << 1, 58 G_WIN32_REGISTRY_WATCH_VALUES = 1 << 2, 59 G_WIN32_REGISTRY_WATCH_SECURITY = 1 << 3, 60 } GWin32RegistryKeyWatcherFlags; 61 62 typedef struct _GWin32RegistryKey GWin32RegistryKey; 63 typedef struct _GWin32RegistryKeyClass GWin32RegistryKeyClass; 64 typedef struct _GWin32RegistryKeyPrivate GWin32RegistryKeyPrivate; 65 typedef struct _GWin32RegistrySubkeyIter GWin32RegistrySubkeyIter; 66 typedef struct _GWin32RegistryValueIter GWin32RegistryValueIter; 67 68 struct _GWin32RegistryKey { 69 GObject parent_instance; 70 71 /*< private >*/ 72 GWin32RegistryKeyPrivate *priv; 73 }; 74 75 struct _GWin32RegistryKeyClass { 76 GObjectClass parent_class; 77 }; 78 79 /** 80 * GWin32RegistryKeyWatchCallbackFunc: 81 * @key: A #GWin32RegistryKey that was watched. 82 * @user_data: The @user_data #gpointer passed to g_win32_registry_key_watch(). 83 * 84 * The type of the callback passed to g_win32_registry_key_watch(). 85 * 86 * The callback is invoked after a change matching the watch flags and arguments 87 * occurs. If the children of the key were watched also, there is no way to know 88 * which one of them triggered the callback. 89 * 90 * Since: 2.42 91 */ 92 typedef void (*GWin32RegistryKeyWatchCallbackFunc) (GWin32RegistryKey *key, 93 gpointer user_data); 94 95 #define G_TYPE_WIN32_REGISTRY_SUBKEY_ITER (g_win32_registry_subkey_iter_get_type ()) 96 97 struct _GWin32RegistrySubkeyIter { 98 /*< private >*/ 99 GWin32RegistryKey *key; 100 gint counter; 101 gint subkey_count; 102 103 gunichar2 *subkey_name; 104 gsize subkey_name_size; 105 gsize subkey_name_len; 106 107 gchar *subkey_name_u8; 108 }; 109 110 #define G_TYPE_WIN32_REGISTRY_VALUE_ITER (g_win32_registry_value_iter_get_type ()) 111 112 struct _GWin32RegistryValueIter { 113 /*< private >*/ 114 GWin32RegistryKey *key; 115 gint counter; 116 gint value_count; 117 118 gunichar2 *value_name; 119 gsize value_name_size; 120 gsize value_name_len; 121 GWin32RegistryValueType value_type; 122 guint8 *value_data; 123 gsize value_data_size; 124 gsize value_actual_data_size; 125 GWin32RegistryValueType value_expanded_type; 126 gunichar2 *value_data_expanded; 127 gsize value_data_expanded_charsize; 128 129 gchar *value_name_u8; 130 gsize value_name_u8_len; 131 gchar *value_data_u8; 132 gsize value_data_u8_size; 133 gchar *value_data_expanded_u8; 134 gsize value_data_expanded_u8_size; 135 }; 136 137 GLIB_AVAILABLE_IN_2_46 138 GWin32RegistrySubkeyIter *g_win32_registry_subkey_iter_copy (const GWin32RegistrySubkeyIter *iter); 139 GLIB_AVAILABLE_IN_2_46 140 void g_win32_registry_subkey_iter_free (GWin32RegistrySubkeyIter *iter); 141 GLIB_AVAILABLE_IN_2_46 142 void g_win32_registry_subkey_iter_assign (GWin32RegistrySubkeyIter *iter, 143 const GWin32RegistrySubkeyIter *other); 144 GLIB_AVAILABLE_IN_2_46 145 GType g_win32_registry_subkey_iter_get_type (void) G_GNUC_CONST; 146 147 148 GLIB_AVAILABLE_IN_2_46 149 GWin32RegistryValueIter *g_win32_registry_value_iter_copy (const GWin32RegistryValueIter *iter); 150 GLIB_AVAILABLE_IN_2_46 151 void g_win32_registry_value_iter_free (GWin32RegistryValueIter *iter); 152 GLIB_AVAILABLE_IN_2_46 153 void g_win32_registry_value_iter_assign (GWin32RegistryValueIter *iter, 154 const GWin32RegistryValueIter *other); 155 GLIB_AVAILABLE_IN_2_46 156 GType g_win32_registry_value_iter_get_type (void) G_GNUC_CONST; 157 158 159 GLIB_AVAILABLE_IN_2_46 160 GType g_win32_registry_key_get_type (void); 161 162 GLIB_AVAILABLE_IN_2_46 163 GWin32RegistryKey *g_win32_registry_key_new (const gchar *path, 164 GError **error); 165 166 GLIB_AVAILABLE_IN_2_46 167 GWin32RegistryKey *g_win32_registry_key_new_w (const gunichar2 *path, 168 GError **error); 169 170 GLIB_AVAILABLE_IN_2_46 171 GWin32RegistryKey *g_win32_registry_key_get_child (GWin32RegistryKey *key, 172 const gchar *subkey, 173 GError **error); 174 175 GLIB_AVAILABLE_IN_2_46 176 GWin32RegistryKey *g_win32_registry_key_get_child_w (GWin32RegistryKey *key, 177 const gunichar2 *subkey, 178 GError **error); 179 180 GLIB_AVAILABLE_IN_2_46 181 gboolean g_win32_registry_subkey_iter_init (GWin32RegistrySubkeyIter *iter, 182 GWin32RegistryKey *key, 183 GError **error); 184 GLIB_AVAILABLE_IN_2_46 185 void g_win32_registry_subkey_iter_clear (GWin32RegistrySubkeyIter *iter); 186 GLIB_AVAILABLE_IN_2_46 187 gsize g_win32_registry_subkey_iter_n_subkeys (GWin32RegistrySubkeyIter *iter); 188 GLIB_AVAILABLE_IN_2_46 189 gboolean g_win32_registry_subkey_iter_next (GWin32RegistrySubkeyIter *iter, 190 gboolean skip_errors, 191 GError **error); 192 GLIB_AVAILABLE_IN_2_46 193 gboolean g_win32_registry_subkey_iter_get_name (GWin32RegistrySubkeyIter *iter, 194 const gchar **subkey_name, 195 gsize *subkey_name_len, 196 GError **error); 197 GLIB_AVAILABLE_IN_2_46 198 gboolean g_win32_registry_subkey_iter_get_name_w (GWin32RegistrySubkeyIter *iter, 199 const gunichar2 **subkey_name, 200 gsize *subkey_name_len, 201 GError **error); 202 203 GLIB_AVAILABLE_IN_2_46 204 gboolean g_win32_registry_value_iter_init (GWin32RegistryValueIter *iter, 205 GWin32RegistryKey *key, 206 GError **error); 207 GLIB_AVAILABLE_IN_2_46 208 void g_win32_registry_value_iter_clear (GWin32RegistryValueIter *iter); 209 GLIB_AVAILABLE_IN_2_46 210 gsize g_win32_registry_value_iter_n_values (GWin32RegistryValueIter *iter); 211 GLIB_AVAILABLE_IN_2_46 212 gboolean g_win32_registry_value_iter_next (GWin32RegistryValueIter *iter, 213 gboolean skip_errors, 214 GError **error); 215 GLIB_AVAILABLE_IN_2_46 216 gboolean g_win32_registry_value_iter_get_value_type (GWin32RegistryValueIter *iter, 217 GWin32RegistryValueType *value_type, 218 GError **error); 219 GLIB_AVAILABLE_IN_2_46 220 gboolean g_win32_registry_value_iter_get_name (GWin32RegistryValueIter *iter, 221 gchar **value_name, 222 gsize *value_name_len, 223 GError **error); 224 GLIB_AVAILABLE_IN_2_46 225 gboolean g_win32_registry_value_iter_get_name_w (GWin32RegistryValueIter *iter, 226 gunichar2 **value_name, 227 gsize *value_name_len, 228 GError **error); 229 GLIB_AVAILABLE_IN_2_46 230 gboolean g_win32_registry_value_iter_get_data (GWin32RegistryValueIter *iter, 231 gboolean auto_expand, 232 gpointer *value_data, 233 gsize *value_data_size, 234 GError **error); 235 GLIB_AVAILABLE_IN_2_46 236 gboolean g_win32_registry_value_iter_get_data_w (GWin32RegistryValueIter *iter, 237 gboolean auto_expand, 238 gpointer *value_data, 239 gsize *value_data_size, 240 GError **error); 241 242 GLIB_AVAILABLE_IN_2_66 243 gboolean g_win32_registry_key_get_value (GWin32RegistryKey *key, 244 const gchar * const *mui_dll_dirs, 245 gboolean auto_expand, 246 const gchar *value_name, 247 GWin32RegistryValueType *value_type, 248 gpointer *value_data, 249 gsize *value_data_size, 250 GError **error); 251 252 GLIB_AVAILABLE_IN_2_66 253 gboolean g_win32_registry_key_get_value_w (GWin32RegistryKey *key, 254 const gunichar2 * const *mui_dll_dirs, 255 gboolean auto_expand, 256 const gunichar2 *value_name, 257 GWin32RegistryValueType *value_type, 258 gpointer *value_data, 259 gsize *value_data_size, 260 GError **error); 261 262 GLIB_AVAILABLE_IN_2_46 263 const gchar *g_win32_registry_key_get_path (GWin32RegistryKey *key); 264 265 GLIB_AVAILABLE_IN_2_46 266 const gunichar2 *g_win32_registry_key_get_path_w (GWin32RegistryKey *key); 267 268 GLIB_AVAILABLE_IN_2_46 269 gboolean g_win32_registry_key_watch (GWin32RegistryKey *key, 270 gboolean watch_children, 271 GWin32RegistryKeyWatcherFlags watch_flags, 272 GWin32RegistryKeyWatchCallbackFunc callback, 273 gpointer user_data, 274 GError **error); 275 GLIB_AVAILABLE_IN_2_46 276 gboolean g_win32_registry_key_has_changed (GWin32RegistryKey *key); 277 278 GLIB_AVAILABLE_IN_2_46 279 void g_win32_registry_key_erase_change_indicator (GWin32RegistryKey *key); 280 281 GLIB_AVAILABLE_IN_2_66 282 const gunichar2 * const *g_win32_registry_get_os_dirs_w (void); 283 284 GLIB_AVAILABLE_IN_2_66 285 const gchar * const *g_win32_registry_get_os_dirs (void); 286 287 G_END_DECLS 288 289 #endif /* G_PLATFORM_WIN32 */ 290 291 #endif /* __G_WIN32_REGISTRY_KEY_H__ */ 292