// Copyright (c) Microsoft Corporation // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #pragma once #include #include #include #include /// /// Manages PowerDisplay.exe process lifecycle and bidirectional IPC communication /// class PowerDisplayProcessManager { private: HANDLE m_hProcess = nullptr; std::unique_ptr m_write_pipe; // Write to PowerDisplay (OUT pipe) HANDLE m_read_pipe = nullptr; // Read from PowerDisplay (IN pipe) - for bidirectional support OnThreadExecutor m_thread_executor; bool m_enabled = false; // Pipe names for this session std::wstring m_pipe_name_out; std::wstring m_pipe_name_in; public: PowerDisplayProcessManager() = default; ~PowerDisplayProcessManager(); /// /// Start PowerDisplay.exe process /// void start(); /// /// Stop PowerDisplay.exe process /// void stop(); /// /// Send message to PowerDisplay.exe /// void send_message_to_powerdisplay(const std::wstring& message); private: /// /// Submit task to thread executor /// void submit_task(std::function task); /// /// Check if PowerDisplay.exe is running /// bool is_process_running() const; /// /// Terminate PowerDisplay.exe process /// void terminate_process(); /// /// Start PowerDisplay.exe with command line arguments /// HRESULT start_process(const std::wstring& pipe_uuid); /// /// Create named pipe for sending commands to PowerDisplay /// HRESULT start_command_pipe(const std::wstring& pipe_uuid); /// /// Refresh - start or stop process based on m_enabled state /// void refresh(); };