The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
5.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the juce_core module of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. or without fee is hereby granted, provided that the above copyright notice and this
  7. permission notice appear in all copies.
  8. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  9. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  10. NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  11. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  12. IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. ------------------------------------------------------------------------------
  15. NOTE! This permissive ISC license applies ONLY to files within the juce_core module!
  16. All other JUCE modules are covered by a dual GPL/commercial license, so if you are
  17. using any other modules, be sure to check that you also comply with their license.
  18. For more details, visit www.juce.com
  19. ==============================================================================
  20. */
  21. #ifndef __JUCE_WINDOWSREGISTRY_JUCEHEADER__
  22. #define __JUCE_WINDOWSREGISTRY_JUCEHEADER__
  23. #if JUCE_WINDOWS || DOXYGEN
  24. /**
  25. Contains some static helper functions for manipulating the MS Windows registry
  26. (Only available on Windows, of course!)
  27. */
  28. class WindowsRegistry
  29. {
  30. public:
  31. //==============================================================================
  32. /** Returns a string from the registry.
  33. The path is a string for the entire path of a value in the registry,
  34. e.g. "HKEY_CURRENT_USER\Software\foo\bar"
  35. */
  36. static String getValue (const String& regValuePath,
  37. const String& defaultValue = String::empty);
  38. /** Returns a string from the WOW64 registry.
  39. The path is a string for the entire path of a value in the registry,
  40. e.g. "HKEY_CURRENT_USER\Software\foo\bar"
  41. */
  42. static String getValueWow64 (const String& regValuePath,
  43. const String& defaultValue = String::empty);
  44. /** Reads a binary block from the registry.
  45. The path is a string for the entire path of a value in the registry,
  46. e.g. "HKEY_CURRENT_USER\Software\foo\bar"
  47. @returns a DWORD indicating the type of the key.
  48. */
  49. static uint32 getBinaryValue (const String& regValuePath, MemoryBlock& resultData);
  50. /** Sets a registry value as a string.
  51. This will take care of creating any groups needed to get to the given registry value.
  52. */
  53. static bool setValue (const String& regValuePath, const String& value);
  54. /** Sets a registry value as a DWORD.
  55. This will take care of creating any groups needed to get to the given registry value.
  56. */
  57. static bool setValue (const String& regValuePath, uint32 value);
  58. /** Sets a registry value as a QWORD.
  59. This will take care of creating any groups needed to get to the given registry value.
  60. */
  61. static bool setValue (const String& regValuePath, uint64 value);
  62. /** Sets a registry value as a binary block.
  63. This will take care of creating any groups needed to get to the given registry value.
  64. */
  65. static bool setValue (const String& regValuePath, const MemoryBlock& value);
  66. /** Returns true if the given value exists in the registry. */
  67. static bool valueExists (const String& regValuePath);
  68. /** Returns true if the given value exists in the registry. */
  69. static bool valueExistsWow64 (const String& regValuePath);
  70. /** Deletes a registry value. */
  71. static void deleteValue (const String& regValuePath);
  72. /** Deletes a registry key (which is registry-talk for 'folder'). */
  73. static void deleteKey (const String& regKeyPath);
  74. /** Creates a file association in the registry.
  75. This lets you set the executable that should be launched by a given file extension.
  76. @param fileExtension the file extension to associate, including the
  77. initial dot, e.g. ".txt"
  78. @param symbolicDescription a space-free short token to identify the file type
  79. @param fullDescription a human-readable description of the file type
  80. @param targetExecutable the executable that should be launched
  81. @param iconResourceNumber the icon that gets displayed for the file type will be
  82. found by looking up this resource number in the
  83. executable. Pass 0 here to not use an icon
  84. @param registerForCurrentUserOnly if false, this will try to register the association
  85. for all users (you might not have permission to do this
  86. unless running in an installer). If true, it will register the
  87. association in HKEY_CURRENT_USER.
  88. */
  89. static bool registerFileAssociation (const String& fileExtension,
  90. const String& symbolicDescription,
  91. const String& fullDescription,
  92. const File& targetExecutable,
  93. int iconResourceNumber,
  94. bool registerForCurrentUserOnly);
  95. private:
  96. WindowsRegistry();
  97. JUCE_DECLARE_NON_COPYABLE (WindowsRegistry)
  98. };
  99. #endif
  100. #endif // __JUCE_WINDOWSREGISTRY_JUCEHEADER__