1 ////////////////////////////////////////////////////////////////////////// 2 // 3 // pgAdmin III - PostgreSQL Tools 4 // RCS-ID: 5 // Copyright (C) 2002 - 2016, The pgAdmin Development Team 6 // This software is released under the PostgreSQL Licence 7 // 8 // registry.h - Windows Registry Reader for both 32 and 64 mode 9 // 10 ////////////////////////////////////////////////////////////////////////// 11 12 #ifndef __PGREG_WINREGISTRY_H__ 13 #define __PGREG_WINREGISTRY_H__ 14 15 #ifdef __WXMSW__ 16 17 #include <windows.h> 18 19 class pgRegKey 20 { 21 22 public: 23 enum PGREGWOWMODE 24 { 25 /* 26 * Read/Write 32 bit registry for 32 bit applications, 27 * Read/Write 64 bit registry for 64 bit applications 28 */ 29 PGREG_WOW_DEFAULT, 30 /* Read/Write 32 bit registry */ 31 PGREG_WOW32, 32 /* Read/Write 64 bit registry on 64 bit windows */ 33 PGREG_WOW64 34 }; 35 36 enum PGREGACCESSMODE 37 { 38 /* READ ONLY */ 39 PGREG_READ, 40 /* READ & Write */ 41 PGREG_WRITE 42 }; 43 44 public: 45 static pgRegKey *OpenRegKey(HKEY root, const wxString &subkey, PGREGACCESSMODE accessmode = PGREG_READ, PGREGWOWMODE wowMode = PGREG_WOW_DEFAULT); 46 ~pgRegKey(); 47 48 static bool KeyExists(HKEY root, const wxString &subKey, PGREGWOWMODE wowMode = PGREG_WOW_DEFAULT); 49 50 bool GetKeyInfo(size_t *pnSubKeys, // number of subkeys 51 size_t *pnMaxKeyLen, // max len of subkey name 52 size_t *pnValues, // number of values 53 size_t *pnMaxValueLen) const; 54 55 bool QueryValue(const wxString &strVal, LPDWORD pVal) const; 56 bool QueryValue(const wxString &strVal, wxString &pVal) const; 57 bool QueryValue(const wxString &strVal, LPBYTE &pVal, DWORD &len) const; 58 59 bool GetFirstValue(wxString &strVal, long &lindex) const; 60 bool GetNextValue(wxString &strVal, long &lindex) const; 61 bool HasValue(const wxString &strVal); 62 63 bool GetFirstKey(pgRegKey *&pkey, long &lindex) const; 64 bool GetNextKey(pgRegKey *&pkey, long &lindex) const; 65 bool HasKey(const wxString &strKey) const; 66 67 DWORD GetValueType(const wxString &strVal) const; 68 69 wxString ToString() const; 70 wxString GetKeyName() const; 71 72 private: 73 pgRegKey(HKEY root, const wxString &subkey, PGREGWOWMODE wowMode, PGREGACCESSMODE accessMode); 74 pgRegKey(const pgRegKey &keyParent, const wxString &strKey); 75 76 void Init(HKEY root, const wxString &subkey, PGREGWOWMODE wowMode, PGREGACCESSMODE accessMode); 77 void Close(); 78 79 HKEY m_hRoot; 80 HKEY m_hKey; 81 wxString m_strName; 82 DWORD m_wowMode; 83 PGREGACCESSMODE m_accessMode; 84 85 }; 86 87 #endif // __WXMSW__ 88 #endif // __PGREG_WINREGISTRY_H__ 89 90