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 3 // found in the LICENSE file. 4 5 #ifndef REMOTING_HOST_WIN_WINDOW_STATION_AND_DESKTOP_H_ 6 #define REMOTING_HOST_WIN_WINDOW_STATION_AND_DESKTOP_H_ 7 8 #include <windows.h> 9 10 #include "base/basictypes.h" 11 12 namespace remoting { 13 14 // Scoper for a pair of window station and desktop handles. Both handles are 15 // closed when the object goes out of scope. 16 class WindowStationAndDesktop { 17 public: 18 WindowStationAndDesktop(); 19 ~WindowStationAndDesktop(); 20 21 HDESK desktop() const { return desktop_; } 22 HWINSTA window_station() const { return window_station_; } 23 24 // Sets a new desktop handle closing the owned desktop handle if needed. 25 void SetDesktop(HDESK desktop); 26 27 // Sets a new window station handle closing the owned window station handle 28 // if needed. 29 void SetWindowStation(HWINSTA window_station); 30 31 // Swaps contents with the other WindowStationAndDesktop. 32 void Swap(WindowStationAndDesktop& other); 33 34 private: 35 HDESK desktop_; 36 HWINSTA window_station_; 37 38 DISALLOW_COPY_AND_ASSIGN(WindowStationAndDesktop); 39 }; 40 41 } // namespace remoting 42 43 #endif // REMOTING_HOST_WIN_WINDOW_STATION_AND_DESKTOP_H_ 44