juce_Process.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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_PROCESS_H_INCLUDED
  22. #define JUCE_PROCESS_H_INCLUDED
  23. //==============================================================================
  24. /** Represents the current executable's process.
  25. This contains methods for controlling the current application at the
  26. process-level.
  27. @see Thread, JUCEApplicationBase
  28. */
  29. class JUCE_API Process
  30. {
  31. public:
  32. //==============================================================================
  33. enum ProcessPriority
  34. {
  35. LowPriority = 0,
  36. NormalPriority = 1,
  37. HighPriority = 2,
  38. RealtimePriority = 3
  39. };
  40. /** Changes the current process's priority.
  41. @param priority the process priority, where
  42. 0=low, 1=normal, 2=high, 3=realtime
  43. */
  44. static void JUCE_CALLTYPE setPriority (const ProcessPriority priority);
  45. /** Kills the current process immediately.
  46. This is an emergency process terminator that kills the application
  47. immediately - it's intended only for use only when something goes
  48. horribly wrong.
  49. @see JUCEApplicationBase::quit
  50. */
  51. static void JUCE_CALLTYPE terminate();
  52. //==============================================================================
  53. /** Returns true if this application process is the one that the user is
  54. currently using.
  55. */
  56. static bool JUCE_CALLTYPE isForegroundProcess();
  57. /** Attempts to make the current process the active one.
  58. (This is not possible on some platforms).
  59. */
  60. static void JUCE_CALLTYPE makeForegroundProcess();
  61. /** Hides the application (on an OS that supports this, e.g. OSX) */
  62. static void JUCE_CALLTYPE hide();
  63. //==============================================================================
  64. /** Raises the current process's privilege level.
  65. Does nothing if this isn't supported by the current OS, or if process
  66. privilege level is fixed.
  67. */
  68. static void JUCE_CALLTYPE raisePrivilege();
  69. /** Lowers the current process's privilege level.
  70. Does nothing if this isn't supported by the current OS, or if process
  71. privilege level is fixed.
  72. */
  73. static void JUCE_CALLTYPE lowerPrivilege();
  74. //==============================================================================
  75. /** Returns true if this process is being hosted by a debugger. */
  76. static bool JUCE_CALLTYPE isRunningUnderDebugger();
  77. //==============================================================================
  78. /** Tries to launch the OS's default reader application for a given file or URL. */
  79. static bool JUCE_CALLTYPE openDocument (const String& documentURL, const String& parameters);
  80. /** Tries to launch the OS's default email application to let the user create a message. */
  81. static bool JUCE_CALLTYPE openEmailWithAttachments (const String& targetEmailAddress,
  82. const String& emailSubject,
  83. const String& bodyText,
  84. const StringArray& filesToAttach);
  85. #if JUCE_WINDOWS || DOXYGEN
  86. //==============================================================================
  87. /** WINDOWS ONLY - This returns the HINSTANCE of the current module.
  88. The return type is a void* to avoid being dependent on windows.h - just cast
  89. it to a HINSTANCE to use it.
  90. In a normal JUCE application, this will be automatically set to the module
  91. handle of the executable.
  92. If you've built a DLL and plan to use any JUCE messaging or windowing classes,
  93. you'll need to make sure you call the setCurrentModuleInstanceHandle()
  94. to provide the correct module handle in your DllMain() function, because
  95. the system relies on the correct instance handle when opening windows.
  96. */
  97. static void* JUCE_CALLTYPE getCurrentModuleInstanceHandle() noexcept;
  98. /** WINDOWS ONLY - Sets a new module handle to be used by the library.
  99. The parameter type is a void* to avoid being dependent on windows.h, but it actually
  100. expects a HINSTANCE value.
  101. @see getCurrentModuleInstanceHandle()
  102. */
  103. static void JUCE_CALLTYPE setCurrentModuleInstanceHandle (void* newHandle) noexcept;
  104. #endif
  105. #if JUCE_MAC || DOXYGEN
  106. //==============================================================================
  107. /** OSX ONLY - Shows or hides the OSX dock icon for this app. */
  108. static void setDockIconVisible (bool isVisible);
  109. #endif
  110. private:
  111. Process();
  112. JUCE_DECLARE_NON_COPYABLE (Process)
  113. };
  114. #endif // JUCE_PROCESS_H_INCLUDED