93fcb70cd50f4a87e0f2e0b3772b6e5e3d7245f8
[reactos.git] / reactos / lib / user32 / misc / winsta.c
1 /* $Id: winsta.c,v 1.15 2004/04/09 20:03:14 navaraf Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS user32.dll
5 * FILE: lib/user32/misc/winsta.c
6 * PURPOSE: Window stations
7 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
8 * UPDATE HISTORY:
9 * 04-06-2001 CSH Created
10 */
11 #include <windows.h>
12 #include <user32.h>
13 #include <debug.h>
14
15
16 /*
17 * @implemented
18 */
19 BOOL STDCALL
20 CloseWindowStation(HWINSTA hWinSta)
21 {
22 return(NtUserCloseWindowStation(hWinSta));
23 }
24
25
26 /*
27 * @implemented
28 */
29 HWINSTA STDCALL
30 CreateWindowStationA(LPSTR lpwinsta,
31 DWORD dwReserved,
32 ACCESS_MASK dwDesiredAccess,
33 LPSECURITY_ATTRIBUTES lpsa)
34 {
35 ANSI_STRING WindowStationNameA;
36 UNICODE_STRING WindowStationNameU;
37 HWINSTA hWinSta;
38
39 if (lpwinsta != NULL)
40 {
41 RtlInitAnsiString(&WindowStationNameA, lpwinsta);
42 RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA,
43 TRUE);
44 }
45 else
46 {
47 RtlInitUnicodeString(&WindowStationNameU, NULL);
48 }
49
50 hWinSta = CreateWindowStationW(WindowStationNameU.Buffer,
51 dwReserved,
52 dwDesiredAccess,
53 lpsa);
54
55 RtlFreeUnicodeString(&WindowStationNameU);
56
57 return hWinSta;
58 }
59
60
61 /*
62 * @implemented
63 */
64 HWINSTA STDCALL
65 CreateWindowStationW(LPWSTR lpwinsta,
66 DWORD dwReserved,
67 ACCESS_MASK dwDesiredAccess,
68 LPSECURITY_ATTRIBUTES lpsa)
69 {
70 UNICODE_STRING WindowStationName;
71
72 RtlInitUnicodeString(&WindowStationName, lpwinsta);
73
74 return NtUserCreateWindowStation(&WindowStationName,
75 dwDesiredAccess,
76 lpsa, 0, 0, 0);
77 }
78
79
80 /*
81 * @unimplemented
82 */
83 BOOL STDCALL
84 EnumWindowStationsA(WINSTAENUMPROCA lpEnumFunc,
85 LPARAM lParam)
86 {
87 UNIMPLEMENTED;
88 return FALSE;
89 }
90
91
92 /*
93 * @unimplemented
94 */
95 BOOL STDCALL
96 EnumWindowStationsW(WINSTAENUMPROCW lpEnumFunc,
97 LPARAM lParam)
98 {
99 PWCHAR Buffer;
100 NTSTATUS Status;
101 ULONG dwRequiredSize;
102 ULONG CurrentEntry, EntryCount;
103
104 Buffer = HeapAlloc(GetProcessHeap(), 0, 200);
105 if (Buffer == NULL)
106 {
107 return FALSE;
108 }
109 Status = NtUserBuildNameList(0, 200, Buffer, &dwRequiredSize);
110 if (Status == STATUS_BUFFER_TOO_SMALL)
111 {
112 Buffer = HeapReAlloc(GetProcessHeap(), 0, Buffer, dwRequiredSize);
113 if (Buffer == NULL)
114 {
115 return FALSE;
116 }
117 Status = NtUserBuildNameList(0, dwRequiredSize, Buffer, &dwRequiredSize);
118 }
119 if (Status != STATUS_SUCCESS)
120 {
121 HeapFree(GetProcessHeap(), 0, Buffer);
122 return FALSE;
123 }
124 EntryCount = *((DWORD *)Buffer);
125 Buffer += sizeof(DWORD) / sizeof(WCHAR);
126 for (CurrentEntry = 0; CurrentEntry < EntryCount; ++CurrentEntry)
127 {
128 (*lpEnumFunc)(Buffer, lParam);
129 Buffer += wcslen(Buffer) + 1;
130 }
131 return TRUE;
132 }
133
134
135 /*
136 * @implemented
137 */
138 HWINSTA STDCALL
139 GetProcessWindowStation(VOID)
140 {
141 return NtUserGetProcessWindowStation();
142 }
143
144
145 /*
146 * @implemented
147 */
148 HWINSTA STDCALL
149 OpenWindowStationA(LPSTR lpszWinSta,
150 BOOL fInherit,
151 ACCESS_MASK dwDesiredAccess)
152 {
153 ANSI_STRING WindowStationNameA;
154 UNICODE_STRING WindowStationNameU;
155 HWINSTA hWinSta;
156
157 if (lpszWinSta != NULL)
158 {
159 RtlInitAnsiString(&WindowStationNameA, lpszWinSta);
160 RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA,
161 TRUE);
162 }
163 else
164 {
165 RtlInitUnicodeString(&WindowStationNameU, NULL);
166 }
167
168 hWinSta = OpenWindowStationW(WindowStationNameU.Buffer,
169 fInherit,
170 dwDesiredAccess);
171
172 RtlFreeUnicodeString(&WindowStationNameU);
173
174 return hWinSta;
175 }
176
177
178 /*
179 * @implemented
180 */
181 HWINSTA STDCALL
182 OpenWindowStationW(LPWSTR lpszWinSta,
183 BOOL fInherit,
184 ACCESS_MASK dwDesiredAccess)
185 {
186 UNICODE_STRING WindowStationName;
187
188 RtlInitUnicodeString(&WindowStationName, lpszWinSta);
189
190 return NtUserOpenWindowStation(&WindowStationName, dwDesiredAccess);
191 }
192
193
194 /*
195 * @implemented
196 */
197 BOOL STDCALL
198 SetProcessWindowStation(HWINSTA hWinSta)
199 {
200 return NtUserSetProcessWindowStation(hWinSta);
201 }
202
203
204 /*
205 * @unimplemented
206 */
207 DWORD
208 STDCALL
209 SetWindowStationUser(
210 DWORD Unknown1,
211 DWORD Unknown2,
212 DWORD Unknown3,
213 DWORD Unknown4
214 )
215 {
216 return NtUserSetWindowStationUser(Unknown1, Unknown2, Unknown3, Unknown4);
217 }
218
219
220 /*
221 * @implemented
222 */
223 BOOL
224 STDCALL
225 LockWindowStation(HWINSTA hWinSta)
226 {
227 return NtUserLockWindowStation(hWinSta);
228 }
229
230
231 /*
232 * @implemented
233 */
234 BOOL
235 STDCALL
236 UnlockWindowStation(HWINSTA hWinSta)
237 {
238 return NtUserUnlockWindowStation(hWinSta);
239 }
240
241 /* EOF */
242