| 127 | } |
| 128 | |
| 129 | std::optional<std::filesystem::path> Window::file() const |
| 130 | { |
| 131 | const auto pid = process_id(); |
| 132 | |
| 133 | if (auto imageName = TryGetNtImageName(pid)) |
| 134 | { |
| 135 | return { std::move(*imageName) }; |
| 136 | } |
| 137 | else |
| 138 | { |
| 139 | const wil::unique_process_handle processHandle(OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid)); |
| 140 | if (!processHandle) |
| 141 | { |
| 142 | LastErrorHandle(spdlog::level::info, L"Getting process handle of a window failed."); |
| 143 | return std::nullopt; |
| 144 | } |
| 145 | |
| 146 | auto [loc, hr] = win32::GetProcessFileName(processHandle.get()); |
| 147 | if (FAILED(hr)) |
| 148 | { |
| 149 | HresultHandle(hr, spdlog::level::info, L"Getting file name of a window failed."); |
| 150 | return std::nullopt; |
| 151 | } |
| 152 | |
| 153 | return { std::move(loc) }; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | std::optional<bool> Window::on_current_desktop() const |
| 158 | { |
no test coverage detected