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