Panda3D
 All Classes Functions Variables Enumerations
windowsRegistry.h
1 // Filename: windowsRegistry.h
2 // Created by: drose (06Aug01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef WINDOWSREGISTRY_H
16 #define WINDOWSREGISTRY_H
17 
18 #include "pandabase.h"
19 
20 // This class is only defined on Windows builds.
21 #ifdef WIN32_VC
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : WindowsRegistry
25 // Description : This class provides a hook to Python to read and
26 // write strings and integers to the windows registry.
27 // It automatically converts strings from utf-8 encoding
28 // and stores them in Unicode (and conversely reconverts
29 // them on retrieval).
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDAEXPRESS WindowsRegistry
32 {
33 PUBLISHED:
34  enum RegLevel {
35  rl_machine = 0,
36  rl_user = 1
37  };
38 
39  static bool set_string_value(const string &key, const string &name,
40  const string &value, RegLevel rl = rl_machine);
41  static bool set_int_value(const string &key, const string &name, int value, RegLevel rl = rl_machine);
42 
43  enum Type {
44  T_none,
45  T_int,
46  T_string,
47  };
48  static Type get_key_type(const string &key, const string &name, RegLevel rl = rl_machine);
49  static string get_string_value(const string &key, const string &name,
50  const string &default_value, RegLevel rl = rl_machine);
51  static int get_int_value(const string &key, const string &name,
52  int default_value, RegLevel rl = rl_machine);
53 
54 private:
55  static bool do_set(const string &key, const string &name,
56  int data_type, const void *data, int data_length, const RegLevel rl);
57  static bool do_get(const string &key, const string &name,
58  int &data_type, string &data, const RegLevel rl);
59  static string format_message(int error_code);
60 };
61 
62 #endif // WIN32_VC
63 
64 #endif