Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cWndDesktop.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cWndDesktop_H
7 #define _INC_cWndDesktop_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
13 
14 #if defined(_WIN32) && ! defined(UNDER_CE)
16 #include "GrayCore/include/cThreadLock.h" // cThreadId
18 
19 namespace Gray
20 {
21  template <> inline void cHandlePtr<HWINSTA>::CloseHandle(HWINSTA h) // static
22  {
24  ::CloseWindowStation(h); // ignored BOOL return.
25  }
26  template <> inline void cHandlePtr<HDESK>::CloseHandle(HDESK h) // static
27  {
29  ::CloseDesktop(h); // ignored BOOL return.
30  }
31 }
32 
33 namespace GrayLib
34 {
35  template< typename _TYPE_HAND >
36  class cWndDesktopT : public cHandlePtr<_TYPE_HAND>
37  {
41 
42  public:
43  bool SetUserObjectInformationX(void* pvInfo, DWORD nLength, int nIndex = 0)
44  {
47  return _GTN(::SetUserObjectInformation)(this->get_Handle(), nIndex, pvInfo, nLength);
48  }
49  };
50 
51  class GRAYLIB_LINK cWndWinStation : public cWndDesktopT<HWINSTA>
52  {
56  public:
57  cWndWinStation(void);
58  ~cWndWinStation(void);
59  HRESULT OpenWindowStationX(const FILECHAR_t* pszName, ACCESS_MASK dwDesiredAccess = STANDARD_RIGHTS_READ);
60 
61  bool SetProcessWindowStation()
62  {
63  return ::SetProcessWindowStation(this->get_Handle());
64  }
65  static HWINSTA inline GetProcessWindowStation()
66  {
68  return ::GetProcessWindowStation();
69  }
70  };
71 
72  class GRAYLIB_LINK cWndDesktop : public cWndDesktopT<HDESK>
73  {
78 
79  public:
80  cWndDesktop(void);
81  ~cWndDesktop(void);
82 
83  HRESULT OpenDesktopX(const FILECHAR_t* pszName, ACCESS_MASK dwDesiredAccess = STANDARD_RIGHTS_READ);
84  HRESULT OpenCreateDesktop(const FILECHAR_t* pszName);
85 
86  static HDESK inline GetThreadDesktop(THREADID_t dwThreadId) noexcept
87  {
90  return ::GetThreadDesktop(dwThreadId);
91  }
92  };
93 };
94 #endif
95 #endif // _INC_cWndDesktop_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define _GTN(c)
_WIN32 name has a A or W for UTF8 or UNICODE (like _FNF)
Definition: StrConst.h:28
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
void CloseHandle()
Definition: cHandlePtr.h:79
Definition: cMesh.h:22
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22