| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/win/wts_terminal_monitor.h" | 5 #include "remoting/host/win/wts_terminal_monitor.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <wtsapi32.h> | 8 #include <wtsapi32.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 DWORD bytes; | 35 DWORD bytes; |
| 36 wchar_t* working_directory; | 36 wchar_t* working_directory; |
| 37 if (!WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, | 37 if (!WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, |
| 38 session_id, | 38 session_id, |
| 39 WTSWorkingDirectory, | 39 WTSWorkingDirectory, |
| 40 &working_directory, | 40 &working_directory, |
| 41 &bytes)) { | 41 &bytes)) { |
| 42 return false; | 42 return false; |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool result = WideToUTF8(working_directory, (bytes / sizeof(wchar_t)) - 1, | 45 bool result = base::WideToUTF8(working_directory, |
| 46 terminal_id); | 46 (bytes / sizeof(wchar_t)) - 1, |
| 47 terminal_id); |
| 47 WTSFreeMemory(working_directory); | 48 WTSFreeMemory(working_directory); |
| 48 return result; | 49 return result; |
| 49 } | 50 } |
| 50 | 51 |
| 51 // static | 52 // static |
| 52 uint32 WtsTerminalMonitor::LookupSessionId(const std::string& terminal_id) { | 53 uint32 WtsTerminalMonitor::LookupSessionId(const std::string& terminal_id) { |
| 53 // Use the fast path if the caller wants to get id of the session attached to | 54 // Use the fast path if the caller wants to get id of the session attached to |
| 54 // the physical console. | 55 // the physical console. |
| 55 if (terminal_id == kConsole) | 56 if (terminal_id == kConsole) |
| 56 return WTSGetActiveConsoleSessionId(); | 57 return WTSGetActiveConsoleSessionId(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 75 | 76 |
| 76 // |terminal_id| is not associated with any session. | 77 // |terminal_id| is not associated with any session. |
| 77 WTSFreeMemory(session_info); | 78 WTSFreeMemory(session_info); |
| 78 return kInvalidSessionId; | 79 return kInvalidSessionId; |
| 79 } | 80 } |
| 80 | 81 |
| 81 WtsTerminalMonitor::WtsTerminalMonitor() { | 82 WtsTerminalMonitor::WtsTerminalMonitor() { |
| 82 } | 83 } |
| 83 | 84 |
| 84 } // namespace remoting | 85 } // namespace remoting |
| OLD | NEW |