From 246f5ec8ec200d456be109b0b8f8b5fa50b7bf8e Mon Sep 17 00:00:00 2001 From: Dmitry Chapyshev Date: Sun, 5 Nov 2023 00:58:02 +0500 Subject: [PATCH] Minor improvements. --- source/base/win/window_station.cc | 6 +++--- source/base/win/window_station.h | 3 +-- source/host/desktop_agent_main.cc | 11 +++-------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/source/base/win/window_station.cc b/source/base/win/window_station.cc index cabb431cea..f220c79b8f 100644 --- a/source/base/win/window_station.cc +++ b/source/base/win/window_station.cc @@ -117,17 +117,17 @@ bool WindowStation::setProcessWindowStation() } //-------------------------------------------------------------------------------------------------- -std::optional WindowStation::name() +std::wstring WindowStation::name() { if (!winsta_) - return std::nullopt; + return std::wstring(); wchar_t buffer[128] = { 0 }; if (!GetUserObjectInformationW(winsta_, UOI_NAME, buffer, sizeof(buffer), nullptr)) { PLOG(LS_ERROR) << "GetUserObjectInformationW failed"; - return std::nullopt; + return std::wstring(); } return buffer; diff --git a/source/base/win/window_station.h b/source/base/win/window_station.h index 1ad8d4c5db..86f0c1222f 100644 --- a/source/base/win/window_station.h +++ b/source/base/win/window_station.h @@ -23,7 +23,6 @@ #include -#include #include #include @@ -43,7 +42,7 @@ class WindowStation bool isValid() const; HWINSTA get() const; bool setProcessWindowStation(); - std::optional name(); + std::wstring name(); void close(); WindowStation& operator=(WindowStation&& other) noexcept; diff --git a/source/host/desktop_agent_main.cc b/source/host/desktop_agent_main.cc index e8d5a496fe..cc2a97c449 100644 --- a/source/host/desktop_agent_main.cc +++ b/source/host/desktop_agent_main.cc @@ -162,15 +162,9 @@ void desktopAgentMain(int argc, const char* const* argv) LOG(LS_INFO) << "Running as user: '" << username << "'"; LOG(LS_INFO) << "Active console session ID: " << WTSGetActiveConsoleSessionId(); LOG(LS_INFO) << "Computer name: '" << base::SysInfo::computerName() << "'"; + LOG(LS_INFO) << "Process WindowStation: " << base::WindowStation::forCurrentProcess().name(); - std::optional process_window_station = - base::WindowStation::forCurrentProcess().name(); - if (process_window_station.has_value()) - { - LOG(LS_INFO) << "Process WindowStation: " << process_window_station.value(); - } - - LOG(LS_INFO) << "Window Stations"; + LOG(LS_INFO) << "WindowStation list"; LOG(LS_INFO) << "#####################################################"; for (const auto& window_station_name : base::WindowStation::windowStationList()) { @@ -191,6 +185,7 @@ void desktopAgentMain(int argc, const char* const* argv) LOG(LS_INFO) << window_station_name << " (desktops: " << desktops << ")"; } + LOG(LS_INFO) << "#####################################################"; LOG(LS_INFO) << "Environment variables"; LOG(LS_INFO) << "#####################################################";