REG.H 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * LAME MP3 encoder for DirectShow
  3. * Registry calls handling class
  4. *
  5. * Copyright (c) 2000-2005 Marie Orlova, Peter Gubanov, Vitaly Ivanov, Elecard Ltd.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. #ifndef __REG__
  23. #define __REG__
  24. namespace Lame
  25. {
  26. class CRegKey
  27. {
  28. protected:
  29. TCHAR m_name[MAX_PATH];
  30. HKEY m_hKey;
  31. HKEY m_hRootKey;
  32. public:
  33. CRegKey(void);
  34. CRegKey(HKEY rootKey, PTSTR pName);
  35. ~CRegKey(void);
  36. BOOL Open(HKEY rootKey, PTSTR pName);
  37. BOOL Create(HKEY rootKey, PTSTR pName);
  38. BOOL Open(PTSTR an = NULL);
  39. BOOL Create(PTSTR an = NULL);
  40. BOOL Close(void);
  41. operator HKEY () const { return m_hKey; };
  42. BOOL getFlag(PTSTR valuename, BOOL bDefault);
  43. void setFlag(PTSTR valuename, BOOL bValue, BOOL bDefault);
  44. void setFlag(PTSTR valuename, BOOL bValue);
  45. DWORD getDWORD(PTSTR valuename, DWORD bDefault);
  46. void setDWORD(PTSTR valuename, DWORD dwValue);
  47. void setDWORD(PTSTR valuename, DWORD dwValue, DWORD dwDefault);
  48. DWORD getString(PTSTR valuename, PTSTR pDefault, PTSTR pResult, int cbSize);
  49. void setString(PTSTR valuename, PTSTR pData);
  50. DWORD getBinary(PTSTR valuename, PVOID pDefault, PVOID pResult, int cbSize);
  51. DWORD setBinary(PTSTR valuename, PVOID pData, int cbSize);
  52. };
  53. class CRegEnumKey
  54. {
  55. public:
  56. CRegEnumKey(HKEY hKey)
  57. {
  58. m_hKey = hKey;
  59. m_dwIndex = 0;
  60. }
  61. ~CRegEnumKey()
  62. {
  63. }
  64. LONG Next(LPTSTR pszStr, DWORD cbName)
  65. {
  66. FILETIME ftLastWriteTime;
  67. LONG lRet = RegEnumKeyEx(m_hKey, m_dwIndex, pszStr,
  68. &cbName, NULL, NULL, NULL, &ftLastWriteTime);
  69. m_dwIndex++;
  70. return lRet;
  71. }
  72. void Reset(void)
  73. {
  74. m_dwIndex = 0;
  75. }
  76. protected:
  77. HKEY m_hKey;
  78. DWORD m_dwIndex;
  79. };
  80. }
  81. #endif // __REG__