desktop.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_
  11. #define MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_
  12. #include <windows.h>
  13. #include <string>
  14. #include "rtc_base/constructor_magic.h"
  15. #include "rtc_base/system/rtc_export.h"
  16. namespace webrtc {
  17. class RTC_EXPORT Desktop {
  18. public:
  19. ~Desktop();
  20. // Returns the name of the desktop represented by the object. Return false if
  21. // quering the name failed for any reason.
  22. bool GetName(std::wstring* desktop_name_out) const;
  23. // Returns true if |other| has the same name as this desktop. Returns false
  24. // in any other case including failing Win32 APIs and uninitialized desktop
  25. // handles.
  26. bool IsSame(const Desktop& other) const;
  27. // Assigns the desktop to the current thread. Returns false is the operation
  28. // failed for any reason.
  29. bool SetThreadDesktop() const;
  30. // Returns the desktop by its name or NULL if an error occurs.
  31. static Desktop* GetDesktop(const wchar_t* desktop_name);
  32. // Returns the desktop currently receiving user input or NULL if an error
  33. // occurs.
  34. static Desktop* GetInputDesktop();
  35. // Returns the desktop currently assigned to the calling thread or NULL if
  36. // an error occurs.
  37. static Desktop* GetThreadDesktop();
  38. private:
  39. Desktop(HDESK desktop, bool own);
  40. // The desktop handle.
  41. HDESK desktop_;
  42. // True if |desktop_| must be closed on teardown.
  43. bool own_;
  44. RTC_DISALLOW_COPY_AND_ASSIGN(Desktop);
  45. };
  46. } // namespace webrtc
  47. #endif // MODULES_DESKTOP_CAPTURE_WIN_DESKTOP_H_