Skip to content

Commit

Permalink
Minor improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
dchapyshev committed Nov 4, 2023
1 parent 2696371 commit 246f5ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
6 changes: 3 additions & 3 deletions source/base/win/window_station.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ bool WindowStation::setProcessWindowStation()
}

//--------------------------------------------------------------------------------------------------
std::optional<std::wstring> 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;
Expand Down
3 changes: 1 addition & 2 deletions source/base/win/window_station.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <Windows.h>

#include <optional>
#include <string>
#include <vector>

Expand All @@ -43,7 +42,7 @@ class WindowStation
bool isValid() const;
HWINSTA get() const;
bool setProcessWindowStation();
std::optional<std::wstring> name();
std::wstring name();
void close();

WindowStation& operator=(WindowStation&& other) noexcept;
Expand Down
11 changes: 3 additions & 8 deletions source/host/desktop_agent_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::wstring> 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())
{
Expand All @@ -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) << "#####################################################";
Expand Down

0 comments on commit 246f5ec

Please sign in to comment.