Panda3D
|
00001 // Filename: windowsRegistry.h 00002 // Created by: drose (06Aug01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef WINDOWSREGISTRY_H 00016 #define WINDOWSREGISTRY_H 00017 00018 #include "pandabase.h" 00019 00020 // This class is only defined on Windows builds. 00021 #ifdef WIN32_VC 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : WindowsRegistry 00025 // Description : This class provides a hook to Python to read and 00026 // write strings and integers to the windows registry. 00027 // It automatically converts strings from utf-8 encoding 00028 // and stores them in Unicode (and conversely reconverts 00029 // them on retrieval). 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDAEXPRESS WindowsRegistry 00032 { 00033 PUBLISHED: 00034 enum RegLevel { 00035 rl_machine = 0, 00036 rl_user = 1 00037 }; 00038 00039 static bool set_string_value(const string &key, const string &name, 00040 const string &value, RegLevel rl = rl_machine); 00041 static bool set_int_value(const string &key, const string &name, int value, RegLevel rl = rl_machine); 00042 00043 enum Type { 00044 T_none, 00045 T_int, 00046 T_string, 00047 }; 00048 static Type get_key_type(const string &key, const string &name, RegLevel rl = rl_machine); 00049 static string get_string_value(const string &key, const string &name, 00050 const string &default_value, RegLevel rl = rl_machine); 00051 static int get_int_value(const string &key, const string &name, 00052 int default_value, RegLevel rl = rl_machine); 00053 00054 private: 00055 static bool do_set(const string &key, const string &name, 00056 int data_type, const void *data, int data_length, const RegLevel rl); 00057 static bool do_get(const string &key, const string &name, 00058 int &data_type, string &data, const RegLevel rl); 00059 static string format_message(int error_code); 00060 }; 00061 00062 #endif // WIN32_VC 00063 00064 #endif