1
0

IPCWindow.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * IPCWindow.h
  3. * -----------
  4. * Purpose: Hidden window to receive file open commands from another OpenMPT instance
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. OPENMPT_NAMESPACE_BEGIN
  12. namespace IPCWindow
  13. {
  14. enum class Function : ULONG
  15. {
  16. Open = 0x01,
  17. SetWindowForeground = 0x02,
  18. GetVersion = 0x03, // returns Version::GewRawVersion()
  19. GetArchitecture = 0x04, // returns mpt::OS::Windows::Architecture
  20. HasSameBinaryPath = 0x05,
  21. HasSameSettingsPath = 0x06
  22. };
  23. void Open(HINSTANCE hInstance);
  24. void Close();
  25. LRESULT SendIPC(HWND ipcWnd, Function function, mpt::const_byte_span data = mpt::const_byte_span());
  26. template <typename Tdata> LRESULT SendIPC(HWND ipcWnd, Function function, mpt::span<const Tdata> data) { return SendIPC(ipcWnd, function, mpt::const_byte_span(reinterpret_cast<const std::byte*>(data.data()), data.size() * sizeof(Tdata))); }
  27. enum InstanceRequirements
  28. {
  29. SamePath = 0x01u,
  30. SameSettings = 0x02u,
  31. SameArchitecture = 0x04u,
  32. SameVersion = 0x08u
  33. };
  34. MPT_DECLARE_ENUM(InstanceRequirements)
  35. HWND FindIPCWindow();
  36. HWND FindIPCWindow(FlagSet<InstanceRequirements> require);
  37. // Send file open requests to other OpenMPT instance, if there is one
  38. bool SendToIPC(const std::vector<mpt::PathString> &filenames);
  39. }
  40. OPENMPT_NAMESPACE_END