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.

144 lines
7.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. #ifndef JUCE_WINDOWSREGISTRY_H_INCLUDED
  24. #define JUCE_WINDOWSREGISTRY_H_INCLUDED
  25. #if JUCE_WINDOWS || DOXYGEN
  26. /**
  27. Contains some static helper functions for manipulating the MS Windows registry
  28. (Only available on Windows, of course!)
  29. */
  30. class JUCE_API WindowsRegistry
  31. {
  32. public:
  33. /** These values can be used to specify whether the 32- or 64-bit registry should be used.
  34. When running on a 32-bit OS, there is no 64-bit registry, so the mode will be ignored.
  35. */
  36. enum WoW64Mode
  37. {
  38. /** Default handling: 32-bit apps will use the 32-bit registry, and 64-bit apps
  39. will use the 64-bit registry. */
  40. WoW64_Default = 0,
  41. /** Always use the 64-bit registry store. (KEY_WOW64_64KEY). */
  42. WoW64_64bit = 0x100,
  43. /** Always use the 32-bit registry store. (KEY_WOW64_32KEY). */
  44. WoW64_32bit = 0x200
  45. };
  46. //==============================================================================
  47. /** Returns a string from the registry.
  48. The path is a string for the entire path of a value in the registry,
  49. e.g. "HKEY_CURRENT_USER\Software\foo\bar"
  50. */
  51. static String JUCE_CALLTYPE getValue (const String& regValuePath,
  52. const String& defaultValue = String(),
  53. WoW64Mode mode = WoW64_Default);
  54. /** Reads a binary block from the registry.
  55. The path is a string for the entire path of a value in the registry,
  56. e.g. "HKEY_CURRENT_USER\Software\foo\bar"
  57. @returns a DWORD indicating the type of the key.
  58. */
  59. static uint32 JUCE_CALLTYPE getBinaryValue (const String& regValuePath, MemoryBlock& resultData, WoW64Mode mode = WoW64_Default);
  60. /** Sets a registry value as a string.
  61. This will take care of creating any groups needed to get to the given registry value.
  62. */
  63. static bool JUCE_CALLTYPE setValue (const String& regValuePath, const String& value, WoW64Mode mode = WoW64_Default);
  64. /** Sets a registry value as a DWORD.
  65. This will take care of creating any groups needed to get to the given registry value.
  66. */
  67. static bool JUCE_CALLTYPE setValue (const String& regValuePath, uint32 value, WoW64Mode mode = WoW64_Default);
  68. /** Sets a registry value as a QWORD.
  69. This will take care of creating any groups needed to get to the given registry value.
  70. */
  71. static bool JUCE_CALLTYPE setValue (const String& regValuePath, uint64 value, WoW64Mode mode = WoW64_Default);
  72. /** Sets a registry value as a binary block.
  73. This will take care of creating any groups needed to get to the given registry value.
  74. */
  75. static bool JUCE_CALLTYPE setValue (const String& regValuePath, const MemoryBlock& value, WoW64Mode mode = WoW64_Default);
  76. /** Returns true if the given value exists in the registry. */
  77. static bool JUCE_CALLTYPE valueExists (const String& regValuePath, WoW64Mode mode = WoW64_Default);
  78. /** Returns true if the given key exists in the registry. */
  79. static bool JUCE_CALLTYPE keyExists (const String& regValuePath, WoW64Mode mode = WoW64_Default);
  80. /** Deletes a registry value. */
  81. static void JUCE_CALLTYPE deleteValue (const String& regValuePath, WoW64Mode mode = WoW64_Default);
  82. /** Deletes a registry key (which is registry-talk for 'folder'). */
  83. static void JUCE_CALLTYPE deleteKey (const String& regKeyPath, WoW64Mode mode = WoW64_Default);
  84. /** Creates a file association in the registry.
  85. This lets you set the executable that should be launched by a given file extension.
  86. @param fileExtension the file extension to associate, including the
  87. initial dot, e.g. ".txt"
  88. @param symbolicDescription a space-free short token to identify the file type
  89. @param fullDescription a human-readable description of the file type
  90. @param targetExecutable the executable that should be launched
  91. @param iconResourceNumber the icon that gets displayed for the file type will be
  92. found by looking up this resource number in the
  93. executable. Pass 0 here to not use an icon
  94. @param registerForCurrentUserOnly if false, this will try to register the association
  95. for all users (you might not have permission to do this
  96. unless running in an installer). If true, it will register the
  97. association in HKEY_CURRENT_USER.
  98. @param mode the WoW64 mode to use for choosing the database
  99. */
  100. static bool JUCE_CALLTYPE registerFileAssociation (const String& fileExtension,
  101. const String& symbolicDescription,
  102. const String& fullDescription,
  103. const File& targetExecutable,
  104. int iconResourceNumber,
  105. bool registerForCurrentUserOnly,
  106. WoW64Mode mode = WoW64_Default);
  107. // DEPRECATED: use the other methods with a WoW64Mode parameter of WoW64_64bit instead.
  108. JUCE_DEPRECATED (static String getValueWow64 (const String&, const String& defaultValue = String()));
  109. JUCE_DEPRECATED (static bool valueExistsWow64 (const String&));
  110. JUCE_DEPRECATED (static bool keyExistsWow64 (const String&));
  111. private:
  112. WindowsRegistry() JUCE_DELETED_FUNCTION;
  113. JUCE_DECLARE_NON_COPYABLE (WindowsRegistry)
  114. };
  115. #endif
  116. #endif // JUCE_WINDOWSREGISTRY_H_INCLUDED