2 * Unit tests for window stations and desktops
4 * Copyright 2002 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <wine/winternl.h>
25 static NTSTATUS (WINAPI
*pNtQueryObject
)(HANDLE
, OBJECT_INFORMATION_CLASS
, PVOID
, ULONG
, PULONG
);
27 #define DESKTOP_ALL_ACCESS 0x01ff
29 static void print_object( HANDLE obj
)
34 strcpy( buffer
, "foobar" );
35 if (!GetUserObjectInformationA( obj
, UOI_NAME
, buffer
, sizeof(buffer
), &size
))
36 trace( "could not get info for %p\n", obj
);
38 trace( "obj %p name '%s'\n", obj
, buffer
);
39 strcpy( buffer
, "foobar" );
40 if (!GetUserObjectInformationA( obj
, UOI_TYPE
, buffer
, sizeof(buffer
), &size
))
41 trace( "could not get type for %p\n", obj
);
43 trace( "obj %p type '%s'\n", obj
, buffer
);
46 static void register_class(void)
50 cls
.style
= CS_DBLCLKS
;
51 cls
.lpfnWndProc
= DefWindowProcA
;
54 cls
.hInstance
= GetModuleHandleA(0);
56 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
57 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
58 cls
.lpszMenuName
= NULL
;
59 cls
.lpszClassName
= "WinStationClass";
63 static HDESK initial_desktop
;
65 static DWORD CALLBACK
thread( LPVOID arg
)
68 HWND hwnd
= CreateWindowExA(0,"WinStationClass","test",WS_POPUP
,0,0,100,100,GetDesktopWindow(),0,0,0);
69 ok( hwnd
!= 0, "CreateWindow failed\n" );
70 d1
= GetThreadDesktop(GetCurrentThreadId());
71 trace( "thread %p desktop: %p\n", arg
, d1
);
72 ok( d1
== initial_desktop
, "thread %p doesn't use initial desktop\n", arg
);
74 SetLastError( 0xdeadbeef );
75 ok( !CloseHandle( d1
), "CloseHandle succeeded\n" );
76 ok( GetLastError() == ERROR_INVALID_HANDLE
, "bad last error %d\n", GetLastError() );
77 SetLastError( 0xdeadbeef );
78 ok( !CloseDesktop( d1
), "CloseDesktop succeeded\n" );
79 ok( GetLastError() == ERROR_BUSY
|| broken(GetLastError() == 0xdeadbeef), /* wow64 */
80 "bad last error %d\n", GetLastError() );
82 d2
= CreateDesktopA( "foobar2", NULL
, NULL
, 0, DESKTOP_ALL_ACCESS
, NULL
);
83 trace( "created desktop %p\n", d2
);
84 ok( d2
!= 0, "CreateDesktop failed\n" );
86 SetLastError( 0xdeadbeef );
87 ok( !SetThreadDesktop( d2
), "set thread desktop succeeded with existing window\n" );
88 ok( GetLastError() == ERROR_BUSY
|| broken(GetLastError() == 0xdeadbeef), /* wow64 */
89 "bad last error %d\n", GetLastError() );
91 DestroyWindow( hwnd
);
92 ok( SetThreadDesktop( d2
), "set thread desktop failed\n" );
93 d1
= GetThreadDesktop(GetCurrentThreadId());
94 ok( d1
== d2
, "GetThreadDesktop did not return set desktop %p/%p\n", d1
, d2
);
98 HANDLE hthread
= CreateThread( NULL
, 0, thread
, (char *)arg
+ 1, 0, NULL
);
100 WaitForSingleObject( hthread
, INFINITE
);
101 CloseHandle( hthread
);
106 static void test_handles(void)
119 w1
= GetProcessWindowStation();
120 ok( GetProcessWindowStation() == w1
, "GetProcessWindowStation returned different handles\n" );
121 ok( !CloseWindowStation(w1
), "closing process win station succeeded\n" );
122 SetLastError( 0xdeadbeef );
123 ok( !CloseHandle(w1
), "closing process win station handle succeeded\n" );
124 ok( GetLastError() == ERROR_INVALID_HANDLE
, "bad last error %d\n", GetLastError() );
128 ok( GetHandleInformation( w1
, &flags
), "GetHandleInformation failed\n" );
129 ok( !(flags
& HANDLE_FLAG_PROTECT_FROM_CLOSE
) ||
130 broken(flags
& HANDLE_FLAG_PROTECT_FROM_CLOSE
), /* set on nt4 */
131 "handle %p PROTECT_FROM_CLOSE set\n", w1
);
133 ok( DuplicateHandle( GetCurrentProcess(), w1
, GetCurrentProcess(), (PHANDLE
)&w2
, 0,
134 TRUE
, DUPLICATE_SAME_ACCESS
), "DuplicateHandle failed\n" );
135 ok( CloseWindowStation(w2
), "closing dup win station failed\n" );
137 ok( DuplicateHandle( GetCurrentProcess(), w1
, GetCurrentProcess(), (PHANDLE
)&w2
, 0,
138 TRUE
, DUPLICATE_SAME_ACCESS
), "DuplicateHandle failed\n" );
139 ok( CloseHandle(w2
), "closing dup win station handle failed\n" );
141 w2
= CreateWindowStationA("WinSta0", 0, WINSTA_ALL_ACCESS
, NULL
);
143 ok( w2
!= 0 || le
== ERROR_ACCESS_DENIED
, "CreateWindowStation failed (%u)\n", le
);
146 ok( w2
!= w1
, "CreateWindowStation returned default handle\n" );
147 SetLastError( 0xdeadbeef );
148 ok( !CloseDesktop( (HDESK
)w2
), "CloseDesktop succeeded on win station\n" );
149 ok( GetLastError() == ERROR_INVALID_HANDLE
|| broken(GetLastError() == 0xdeadbeef), /* wow64 */
150 "bad last error %d\n", GetLastError() );
151 ok( CloseWindowStation( w2
), "CloseWindowStation failed\n" );
153 w2
= CreateWindowStationA("WinSta0", 0, WINSTA_ALL_ACCESS
, NULL
);
154 ok( CloseHandle( w2
), "CloseHandle failed\n" );
156 else if (le
== ERROR_ACCESS_DENIED
)
157 win_skip( "Not enough privileges for CreateWindowStation\n" );
159 w2
= OpenWindowStationA("winsta0", TRUE
, WINSTA_ALL_ACCESS
);
160 ok( w2
!= 0, "OpenWindowStation failed\n" );
161 ok( w2
!= w1
, "OpenWindowStation returned default handle\n" );
162 ok( CloseWindowStation( w2
), "CloseWindowStation failed\n" );
164 w2
= OpenWindowStationA("dummy name", TRUE
, WINSTA_ALL_ACCESS
);
165 ok( !w2
, "open dummy win station succeeded\n" );
167 CreateMutexA( NULL
, 0, "foobar" );
168 w2
= CreateWindowStationA("foobar", 0, WINSTA_ALL_ACCESS
, NULL
);
170 ok( w2
!= 0 || le
== ERROR_ACCESS_DENIED
, "create foobar station failed (%u)\n", le
);
174 w3
= OpenWindowStationA("foobar", TRUE
, WINSTA_ALL_ACCESS
);
175 ok( w3
!= 0, "open foobar station failed\n" );
176 ok( w3
!= w2
, "open foobar station returned same handle\n" );
177 ok( CloseWindowStation( w2
), "CloseWindowStation failed\n" );
178 ok( CloseWindowStation( w3
), "CloseWindowStation failed\n" );
180 w3
= OpenWindowStationA("foobar", TRUE
, WINSTA_ALL_ACCESS
);
181 ok( !w3
, "open foobar station succeeded\n" );
183 w2
= CreateWindowStationA("foobar1", 0, WINSTA_ALL_ACCESS
, NULL
);
184 ok( w2
!= 0, "create foobar station failed\n" );
185 w3
= CreateWindowStationA("foobar2", 0, WINSTA_ALL_ACCESS
, NULL
);
186 ok( w3
!= 0, "create foobar station failed\n" );
187 ok( GetHandleInformation( w2
, &flags
), "GetHandleInformation failed\n" );
188 ok( GetHandleInformation( w3
, &flags
), "GetHandleInformation failed\n" );
190 SetProcessWindowStation( w2
);
191 atom
= GlobalAddAtomA("foo");
192 ok( GlobalGetAtomNameA( atom
, buffer
, sizeof(buffer
) ) == 3, "GlobalGetAtomName failed\n" );
193 ok( !lstrcmpiA( buffer
, "foo" ), "bad atom value %s\n", buffer
);
195 ok( !CloseWindowStation( w2
), "CloseWindowStation succeeded\n" );
196 ok( GetHandleInformation( w2
, &flags
), "GetHandleInformation failed\n" );
198 SetProcessWindowStation( w3
);
199 ok( GetHandleInformation( w2
, &flags
), "GetHandleInformation failed\n" );
200 ok( CloseWindowStation( w2
), "CloseWindowStation failed\n" );
201 ok( GlobalGetAtomNameA( atom
, buffer
, sizeof(buffer
) ) == 3, "GlobalGetAtomName failed\n" );
202 ok( !lstrcmpiA( buffer
, "foo" ), "bad atom value %s\n", buffer
);
204 else if (le
== ERROR_ACCESS_DENIED
)
205 win_skip( "Not enough privileges for CreateWindowStation\n" );
207 SetLastError( 0xdeadbeef );
208 w2
= OpenWindowStationA( "", TRUE
, WINSTA_ALL_ACCESS
);
209 ok( !w2
, "open station succeeded\n" );
211 ok( GetLastError() == ERROR_FILE_NOT_FOUND
, "wrong error %u\n", GetLastError() );
213 SetLastError( 0xdeadbeef );
214 w2
= CreateWindowStationA( "", 0, WINSTA_ALL_ACCESS
, NULL
);
215 ok( w2
!= 0, "create station failed err %u\n", GetLastError() );
217 memset( buffer
, 0, sizeof(buffer
) );
218 ret
= GetUserObjectInformationA( w2
, UOI_NAME
, buffer
, sizeof(buffer
), &size
);
219 ok( ret
, "GetUserObjectInformationA failed with error %u\n", GetLastError() );
220 ok( !memcmp(buffer
, "Service-0x0-", 12), "unexpected window station name '%s'\n", buffer
);
221 ok( buffer
[strlen(buffer
) - 1] == '$', "unexpected window station name '%s'\n", buffer
);
223 SetLastError( 0xdeadbeef );
224 w3
= OpenWindowStationA( "", TRUE
, WINSTA_ALL_ACCESS
);
226 ok( w3
!= 0, "open station failed err %u\n", GetLastError() );
227 CloseWindowStation( w3
);
228 CloseWindowStation( w2
);
230 SetLastError( 0xdeadbeef );
231 w2
= CreateWindowStationA( "foo\\bar", 0, WINSTA_ALL_ACCESS
, NULL
);
232 ok( !w2
, "create station succeeded\n" );
233 ok( GetLastError() == ERROR_PATH_NOT_FOUND
|| GetLastError() == ERROR_ACCESS_DENIED
,
234 "wrong error %u\n", GetLastError() );
236 SetLastError( 0xdeadbeef );
237 w2
= OpenWindowStationA( "foo\\bar", TRUE
, WINSTA_ALL_ACCESS
);
238 ok( !w2
, "create station succeeded\n" );
239 ok( GetLastError() == ERROR_PATH_NOT_FOUND
, "wrong error %u\n", GetLastError() );
242 d1
= GetThreadDesktop(GetCurrentThreadId());
243 initial_desktop
= d1
;
244 ok( GetThreadDesktop(GetCurrentThreadId()) == d1
,
245 "GetThreadDesktop returned different handles\n" );
248 ok( GetHandleInformation( d1
, &flags
), "GetHandleInformation failed\n" );
249 ok( !(flags
& HANDLE_FLAG_PROTECT_FROM_CLOSE
), "handle %p PROTECT_FROM_CLOSE set\n", d1
);
251 SetLastError( 0xdeadbeef );
252 ok( !CloseDesktop(d1
), "closing thread desktop succeeded\n" );
253 ok( GetLastError() == ERROR_BUSY
|| broken(GetLastError() == 0xdeadbeef), /* wow64 */
254 "bad last error %d\n", GetLastError() );
256 SetLastError( 0xdeadbeef );
257 if (CloseHandle( d1
)) /* succeeds on nt4 */
259 win_skip( "NT4 desktop handle management is completely different\n" );
262 ok( GetLastError() == ERROR_INVALID_HANDLE
, "bad last error %d\n", GetLastError() );
264 ok( DuplicateHandle( GetCurrentProcess(), d1
, GetCurrentProcess(), (PHANDLE
)&d2
, 0,
265 TRUE
, DUPLICATE_SAME_ACCESS
), "DuplicateHandle failed\n" );
266 ok( CloseDesktop(d2
), "closing dup desktop failed\n" );
268 ok( DuplicateHandle( GetCurrentProcess(), d1
, GetCurrentProcess(), (PHANDLE
)&d2
, 0,
269 TRUE
, DUPLICATE_SAME_ACCESS
), "DuplicateHandle failed\n" );
270 ok( CloseHandle(d2
), "closing dup desktop handle failed\n" );
272 d2
= OpenDesktopA( "dummy name", 0, TRUE
, DESKTOP_ALL_ACCESS
);
273 ok( !d2
, "open dummy desktop succeeded\n" );
275 SetLastError( 0xdeadbeef );
276 d2
= CreateDesktopA( "", NULL
, NULL
, 0, DESKTOP_ALL_ACCESS
, NULL
);
278 ok( !d2
, "create empty desktop succeeded\n" );
280 ok( GetLastError() == ERROR_INVALID_HANDLE
, "wrong error %u\n", GetLastError() );
282 SetLastError( 0xdeadbeef );
283 d2
= OpenDesktopA( "", 0, TRUE
, DESKTOP_ALL_ACCESS
);
284 ok( !d2
, "open empty desktop succeeded\n" );
285 ok( GetLastError() == ERROR_INVALID_HANDLE
, "wrong error %u\n", GetLastError() );
287 SetLastError( 0xdeadbeef );
288 d2
= CreateDesktopA( "foo\\bar", NULL
, NULL
, 0, DESKTOP_ALL_ACCESS
, NULL
);
289 ok( !d2
, "create desktop succeeded\n" );
290 ok( GetLastError() == ERROR_BAD_PATHNAME
, "wrong error %u\n", GetLastError() );
292 SetLastError( 0xdeadbeef );
293 d2
= OpenDesktopA( "foo\\bar", 0, TRUE
, DESKTOP_ALL_ACCESS
);
294 ok( !d2
, "open desktop succeeded\n" );
295 ok( GetLastError() == ERROR_BAD_PATHNAME
, "wrong error %u\n", GetLastError() );
297 d2
= CreateDesktopA( "foobar", NULL
, NULL
, 0, DESKTOP_ALL_ACCESS
, NULL
);
298 ok( d2
!= 0, "create foobar desktop failed\n" );
299 SetLastError( 0xdeadbeef );
300 ok( !CloseWindowStation( (HWINSTA
)d2
), "CloseWindowStation succeeded on desktop\n" );
301 ok( GetLastError() == ERROR_INVALID_HANDLE
|| broken(GetLastError() == 0xdeadbeef), /* wow64 */
302 "bad last error %d\n", GetLastError() );
304 SetLastError( 0xdeadbeef );
305 d3
= CreateDesktopA( "foobar", NULL
, NULL
, 0, DESKTOP_ALL_ACCESS
, NULL
);
306 ok( d3
!= 0, "create foobar desktop again failed\n" );
307 ok( GetLastError() == 0xdeadbeef, "bad last error %d\n", GetLastError() );
308 ok( CloseDesktop( d3
), "CloseDesktop failed\n" );
310 d3
= OpenDesktopA( "foobar", 0, TRUE
, DESKTOP_ALL_ACCESS
);
311 ok( d3
!= 0, "open foobar desktop failed\n" );
312 ok( d3
!= d2
, "open foobar desktop returned same handle\n" );
313 ok( CloseDesktop( d2
), "CloseDesktop failed\n" );
314 ok( CloseDesktop( d3
), "CloseDesktop failed\n" );
316 d3
= OpenDesktopA( "foobar", 0, TRUE
, DESKTOP_ALL_ACCESS
);
317 ok( !d3
, "open foobar desktop succeeded\n" );
319 ok( !CloseHandle(d1
), "closing thread desktop handle succeeded\n" );
320 d2
= GetThreadDesktop(GetCurrentThreadId());
321 ok( d1
== d2
, "got different handles after close\n" );
324 trace( "thread 1 desktop: %p\n", d1
);
326 hthread
= CreateThread( NULL
, 0, thread
, (LPVOID
)2, 0, &id
);
328 trace( "get other thread desktop: %p\n", GetThreadDesktop(id
) );
329 WaitForSingleObject( hthread
, INFINITE
);
330 CloseHandle( hthread
);
332 /* clean side effect */
333 SetProcessWindowStation( w1
);
336 /* Enumeration tests */
338 static BOOL CALLBACK
window_station_callbackA(LPSTR winsta
, LPARAM lp
)
340 trace("window_station_callbackA called with argument %s\n", winsta
);
344 static BOOL CALLBACK
open_window_station_callbackA(LPSTR winsta
, LPARAM lp
)
348 trace("open_window_station_callbackA called with argument %s\n", winsta
);
349 hwinsta
= OpenWindowStationA(winsta
, FALSE
, WINSTA_ENUMERATE
);
350 ok(hwinsta
!= NULL
, "Could not open desktop %s!\n", winsta
);
352 CloseWindowStation(hwinsta
);
356 static void test_enumstations(void)
361 if (0) /* Crashes instead */
363 SetLastError(0xbabefeed);
364 ret
= EnumWindowStationsA(NULL
, 0);
365 ok(!ret
, "EnumWindowStationsA returned successfully!\n");
366 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "LastError is set to %08x\n", GetLastError());
369 hwinsta
= CreateWindowStationA("winsta_test", 0, WINSTA_ALL_ACCESS
, NULL
);
370 ret
= GetLastError();
371 ok(hwinsta
!= NULL
|| ret
== ERROR_ACCESS_DENIED
, "CreateWindowStation failed (%u)\n", ret
);
374 win_skip("Not enough privileges for CreateWindowStation\n");
378 SetLastError(0xdeadbeef);
379 ret
= EnumWindowStationsA(open_window_station_callbackA
, 0x12345);
380 ok(ret
== 0x12345, "EnumWindowStationsA returned %x\n", ret
);
381 ok(GetLastError() == 0xdeadbeef, "LastError is set to %08x\n", GetLastError());
383 SetLastError(0xdeadbeef);
384 ret
= EnumWindowStationsA(window_station_callbackA
, 0);
385 ok(!ret
, "EnumWindowStationsA returned %x\n", ret
);
386 ok(GetLastError() == 0xdeadbeef, "LastError is set to %08x\n", GetLastError());
389 static BOOL CALLBACK
desktop_callbackA(LPSTR desktop
, LPARAM lp
)
391 trace("desktop_callbackA called with argument %s\n", desktop
);
395 static BOOL CALLBACK
open_desktop_callbackA(LPSTR desktop
, LPARAM lp
)
400 trace("open_desktop_callbackA called with argument %s\n", desktop
);
401 /* Only try to open one desktop */
405 hdesk
= OpenDesktopA(desktop
, 0, FALSE
, DESKTOP_ENUMERATE
);
406 ok(hdesk
!= NULL
, "Could not open desktop %s!\n", desktop
);
412 static void test_enumdesktops(void)
416 if (0) /* Crashes instead */
418 SetLastError(0xbabefeed);
419 ret
= EnumDesktopsA(GetProcessWindowStation(), NULL
, 0);
420 ok(!ret
, "EnumDesktopsA returned successfully!\n");
421 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "LastError is set to %08x\n", GetLastError());
424 SetLastError(0xdeadbeef);
425 ret
= EnumDesktopsA(NULL
, desktop_callbackA
, 0x12345);
426 ok(ret
== 0x12345, "EnumDesktopsA returned %x\n", ret
);
427 ok(GetLastError() == 0xdeadbeef, "LastError is set to %08x\n", GetLastError());
429 SetLastError(0xdeadbeef);
430 ret
= EnumDesktopsA(GetProcessWindowStation(), open_desktop_callbackA
, 0x12345);
431 ok(ret
== 0x12345, "EnumDesktopsA returned %x\n", ret
);
432 ok(GetLastError() == 0xdeadbeef, "LastError is set to %08x\n", GetLastError());
434 SetLastError(0xdeadbeef);
435 ret
= EnumDesktopsA(INVALID_HANDLE_VALUE
, desktop_callbackA
, 0x12345);
436 ok(!ret
, "EnumDesktopsA returned %x\n", ret
);
437 ok(GetLastError() == ERROR_INVALID_HANDLE
, "LastError is set to %08x\n", GetLastError());
439 SetLastError(0xdeadbeef);
440 ret
= EnumDesktopsA(GetProcessWindowStation(), desktop_callbackA
, 0);
441 ok(!ret
, "EnumDesktopsA returned %x\n", ret
);
442 ok(GetLastError() == 0xdeadbeef, "LastError is set to %08x\n", GetLastError());
445 /* Miscellaneous tests */
447 static void test_getuserobjectinformation(void)
449 WCHAR foobarTestW
[] = {'\\','f','o','o','b','a','r','T','e','s','t',0};
450 WCHAR DesktopW
[] = {'D','e','s','k','t','o','p',0};
451 OBJECT_NAME_INFORMATION
*name_info
;
459 desk
= CreateDesktopA("foobarTest", NULL
, NULL
, 0, DESKTOP_ALL_ACCESS
, NULL
);
460 ok(desk
!= 0, "open foobarTest desktop failed\n");
462 strcpy(buffer
, "blahblah");
464 /** Tests for UOI_NAME **/
466 /* Get size, test size and return value/error code */
467 SetLastError(0xdeadbeef);
469 ret
= GetUserObjectInformationA(desk
, UOI_NAME
, NULL
, 0, &size
);
471 ok(!ret
, "GetUserObjectInformationA returned %x\n", ret
);
472 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "LastError is set to %08x\n", GetLastError());
473 ok(size
== 22, "size is set to %d\n", size
); /* Windows returns Unicode length (11*2) */
476 SetLastError(0xdeadbeef);
478 ret
= GetUserObjectInformationA(desk
, UOI_NAME
, buffer
, sizeof(buffer
), &size
);
480 ok(ret
, "GetUserObjectInformationA returned %x\n", ret
);
481 ok(GetLastError() == 0xdeadbeef, "LastError is set to %08x\n", GetLastError());
483 ok(strcmp(buffer
, "foobarTest") == 0, "Buffer is set to '%s'\n", buffer
);
484 ok(size
== 11, "size is set to %d\n", size
); /* 11 bytes in 'foobarTest\0' */
486 /* Get size, test size and return value/error code (Unicode) */
487 SetLastError(0xdeadbeef);
489 ret
= GetUserObjectInformationW(desk
, UOI_NAME
, NULL
, 0, &size
);
491 ok(!ret
, "GetUserObjectInformationW returned %x\n", ret
);
492 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "LastError is set to %08x\n", GetLastError());
493 ok(size
== 22, "size is set to %d\n", size
); /* 22 bytes in 'foobarTest\0' in Unicode */
495 /* Get string (Unicode) */
496 SetLastError(0xdeadbeef);
498 ret
= GetUserObjectInformationW(desk
, UOI_NAME
, bufferW
, sizeof(bufferW
), &size
);
500 ok(ret
, "GetUserObjectInformationW returned %x\n", ret
);
501 ok(GetLastError() == 0xdeadbeef, "LastError is set to %08x\n", GetLastError());
503 ok(lstrcmpW(bufferW
, foobarTestW
+ 1) == 0, "Buffer is not set to 'foobarTest'\n");
504 ok(size
== 22, "size is set to %d\n", size
); /* 22 bytes in 'foobarTest\0' in Unicode */
506 /* ObjectNameInformation does not return the full desktop name */
507 name_info
= (OBJECT_NAME_INFORMATION
*)buffer
;
508 status
= pNtQueryObject(desk
, ObjectNameInformation
, name_info
, sizeof(buffer
), NULL
);
509 ok(!status
, "expected STATUS_SUCCESS, got %08x\n", status
);
510 ok(lstrcmpW(name_info
->Name
.Buffer
, foobarTestW
) == 0,
511 "expected '\\foobarTest', got %s\n", wine_dbgstr_w(name_info
->Name
.Buffer
));
513 /** Tests for UOI_TYPE **/
515 /* Get size, test size and return value/error code */
516 SetLastError(0xdeadbeef);
518 ret
= GetUserObjectInformationA(desk
, UOI_TYPE
, NULL
, 0, &size
);
520 ok(!ret
, "GetUserObjectInformationA returned %x\n", ret
);
521 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "LastError is set to %08x\n", GetLastError());
522 ok(size
== 16, "size is set to %d\n", size
); /* Windows returns Unicode length (8*2) */
525 SetLastError(0xdeadbeef);
527 ret
= GetUserObjectInformationA(desk
, UOI_TYPE
, buffer
, sizeof(buffer
), &size
);
529 ok(ret
, "GetUserObjectInformationA returned %x\n", ret
);
530 ok(GetLastError() == 0xdeadbeef, "LastError is set to %08x\n", GetLastError());
532 ok(strcmp(buffer
, "Desktop") == 0, "Buffer is set to '%s'\n", buffer
);
533 ok(size
== 8, "size is set to %d\n", size
); /* 8 bytes in 'Desktop\0' */
535 /* Get size, test size and return value/error code (Unicode) */
537 SetLastError(0xdeadbeef);
538 ret
= GetUserObjectInformationW(desk
, UOI_TYPE
, NULL
, 0, &size
);
540 ok(!ret
, "GetUserObjectInformationW returned %x\n", ret
);
541 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "LastError is set to %08x\n", GetLastError());
542 ok(size
== 16, "size is set to %d\n", size
); /* 16 bytes in 'Desktop\0' in Unicode */
544 /* Get string (Unicode) */
545 SetLastError(0xdeadbeef);
547 ret
= GetUserObjectInformationW(desk
, UOI_TYPE
, bufferW
, sizeof(bufferW
), &size
);
549 ok(ret
, "GetUserObjectInformationW returned %x\n", ret
);
550 ok(GetLastError() == 0xdeadbeef, "LastError is set to %08x\n", GetLastError());
552 ok(lstrcmpW(bufferW
, DesktopW
) == 0, "Buffer is not set to 'Desktop'\n");
553 ok(size
== 16, "size is set to %d\n", size
); /* 16 bytes in 'Desktop\0' in Unicode */
555 ok(CloseDesktop(desk
), "CloseDesktop failed\n");
558 static void test_inputdesktop(void)
560 HDESK input_desk
, old_input_desk
, thread_desk
, old_thread_desk
, new_desk
;
565 inputs
[0].type
= INPUT_KEYBOARD
;
566 U(inputs
[0]).ki
.wVk
= 0;
567 U(inputs
[0]).ki
.wScan
= 0x3c0;
568 U(inputs
[0]).ki
.dwFlags
= KEYEVENTF_UNICODE
;
570 /* OpenInputDesktop creates new handles for each calls */
571 old_input_desk
= OpenInputDesktop(0, FALSE
, DESKTOP_ALL_ACCESS
);
572 ok(old_input_desk
!= NULL
, "OpenInputDesktop failed!\n");
573 memset(name
, 0, sizeof(name
));
574 ret
= GetUserObjectInformationA(old_input_desk
, UOI_NAME
, name
, 1024, NULL
);
575 ok(ret
, "GetUserObjectInformation failed!\n");
576 ok(!strcmp(name
, "Default"), "unexpected desktop %s\n", name
);
578 input_desk
= OpenInputDesktop(0, FALSE
, DESKTOP_ALL_ACCESS
);
579 ok(input_desk
!= NULL
, "OpenInputDesktop failed!\n");
580 memset(name
, 0, sizeof(name
));
581 ret
= GetUserObjectInformationA(input_desk
, UOI_NAME
, name
, 1024, NULL
);
582 ok(ret
, "GetUserObjectInformation failed!\n");
583 ok(!strcmp(name
, "Default"), "unexpected desktop %s\n", name
);
585 ok(old_input_desk
!= input_desk
, "returned the same handle!\n");
586 ret
= CloseDesktop(input_desk
);
587 ok(ret
, "CloseDesktop failed!\n");
589 /* by default, GetThreadDesktop is the input desktop, SendInput should succeed. */
590 old_thread_desk
= GetThreadDesktop(GetCurrentThreadId());
591 ok(old_thread_desk
!= NULL
, "GetThreadDesktop faile!\n");
592 memset(name
, 0, sizeof(name
));
593 ret
= GetUserObjectInformationA(old_thread_desk
, UOI_NAME
, name
, 1024, NULL
);
594 ok(!strcmp(name
, "Default"), "unexpected desktop %s\n", name
);
596 SetLastError(0xdeadbeef);
597 ret
= SendInput(1, inputs
, sizeof(INPUT
));
598 ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError());
599 ok(ret
== 1, "unexpected return count %d\n", ret
);
601 /* Set thread desktop to the new desktop, SendInput should fail. */
602 new_desk
= CreateDesktopA("new_desk", NULL
, NULL
, 0, DESKTOP_ALL_ACCESS
, NULL
);
603 ok(new_desk
!= NULL
, "CreateDesktop failed!\n");
604 ret
= SetThreadDesktop(new_desk
);
605 ok(ret
, "SetThreadDesktop failed!\n");
606 thread_desk
= GetThreadDesktop(GetCurrentThreadId());
607 ok(thread_desk
== new_desk
, "thread desktop doesn't match!\n");
608 memset(name
, 0, sizeof(name
));
609 ret
= GetUserObjectInformationA(thread_desk
, UOI_NAME
, name
, 1024, NULL
);
610 ok(!strcmp(name
, "new_desk"), "unexpected desktop %s\n", name
);
612 SetLastError(0xdeadbeef);
613 ret
= SendInput(1, inputs
, sizeof(INPUT
));
614 if(broken(GetLastError() == 0xdeadbeef))
616 SetThreadDesktop(old_thread_desk
);
617 CloseDesktop(old_input_desk
);
618 CloseDesktop(input_desk
);
619 CloseDesktop(new_desk
);
620 win_skip("Skip tests on NT4\n");
624 ok(GetLastError() == ERROR_ACCESS_DENIED
, "unexpected last error %08x\n", GetLastError());
625 ok(ret
== 1 || broken(ret
== 0) /* Win64 */, "unexpected return count %d\n", ret
);
627 /* Set thread desktop back to the old thread desktop, SendInput should success. */
628 ret
= SetThreadDesktop(old_thread_desk
);
629 ok(ret
, "SetThreadDesktop failed!\n");
630 thread_desk
= GetThreadDesktop(GetCurrentThreadId());
631 ok(thread_desk
== old_thread_desk
, "thread desktop doesn't match!\n");
632 memset(name
, 0, sizeof(name
));
633 ret
= GetUserObjectInformationA(thread_desk
, UOI_NAME
, name
, 1024, NULL
);
634 ok(!strcmp(name
, "Default"), "unexpected desktop %s\n", name
);
636 SetLastError(0xdeadbeef);
637 ret
= SendInput(1, inputs
, sizeof(INPUT
));
638 ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError());
639 ok(ret
== 1, "unexpected return count %d\n", ret
);
641 /* Set thread desktop to the input desktop, SendInput should success. */
642 ret
= SetThreadDesktop(old_input_desk
);
643 ok(ret
, "SetThreadDesktop failed!\n");
644 thread_desk
= GetThreadDesktop(GetCurrentThreadId());
645 ok(thread_desk
== old_input_desk
, "thread desktop doesn't match!\n");
646 memset(name
, 0, sizeof(name
));
647 ret
= GetUserObjectInformationA(thread_desk
, UOI_NAME
, name
, 1024, NULL
);
648 ok(!strcmp(name
, "Default"), "unexpected desktop %s\n", name
);
650 SetLastError(0xdeadbeef);
651 ret
= SendInput(1, inputs
, sizeof(INPUT
));
652 ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError());
653 ok(ret
== 1, "unexpected return count %d\n", ret
);
655 /* Switch input desktop to the new desktop, SendInput should fail. */
656 ret
= SwitchDesktop(new_desk
);
657 ok(ret
, "SwitchDesktop failed!\n");
658 input_desk
= OpenInputDesktop(0, FALSE
, DESKTOP_ALL_ACCESS
);
659 ok(input_desk
!= NULL
, "OpenInputDesktop failed!\n");
660 ok(input_desk
!= new_desk
, "returned the same handle!\n");
661 memset(name
, 0, sizeof(name
));
662 ret
= GetUserObjectInformationA(input_desk
, UOI_NAME
, name
, 1024, NULL
);
663 ok(ret
, "GetUserObjectInformation failed!\n");
665 ok(!strcmp(name
, "new_desk"), "unexpected desktop %s\n", name
);
666 ret
= CloseDesktop(input_desk
);
667 ok(ret
, "CloseDesktop failed!\n");
669 SetLastError(0xdeadbeef);
670 ret
= SendInput(1, inputs
, sizeof(INPUT
));
672 ok(GetLastError() == ERROR_ACCESS_DENIED
, "unexpected last error %08x\n", GetLastError());
673 ok(ret
== 1 || broken(ret
== 0) /* Win64 */, "unexpected return count %d\n", ret
);
675 /* Set thread desktop to the new desktop, SendInput should success. */
676 ret
= SetThreadDesktop(new_desk
);
677 ok(ret
, "SetThreadDesktop failed!\n");
678 thread_desk
= GetThreadDesktop(GetCurrentThreadId());
679 ok(thread_desk
== new_desk
, "thread desktop doesn't match!\n");
680 memset(name
, 0, sizeof(name
));
681 ret
= GetUserObjectInformationA(thread_desk
, UOI_NAME
, name
, 1024, NULL
);
682 ok(!strcmp(name
, "new_desk"), "unexpected desktop %s\n", name
);
684 SetLastError(0xdeadbeef);
685 ret
= SendInput(1, inputs
, sizeof(INPUT
));
686 ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError());
687 ok(ret
== 1, "unexpected return count %d\n", ret
);
689 /* Switch input desktop to the old input desktop, set thread desktop to the old
690 * thread desktop, clean side effects. SendInput should success. */
691 ret
= SwitchDesktop(old_input_desk
);
692 input_desk
= OpenInputDesktop(0, FALSE
, DESKTOP_ALL_ACCESS
);
693 ok(input_desk
!= NULL
, "OpenInputDesktop failed!\n");
694 ok(input_desk
!= old_input_desk
, "returned the same handle!\n");
695 memset(name
, 0, sizeof(name
));
696 ret
= GetUserObjectInformationA(input_desk
, UOI_NAME
, name
, 1024, NULL
);
697 ok(ret
, "GetUserObjectInformation failed!\n");
698 ok(!strcmp(name
, "Default"), "unexpected desktop %s\n", name
);
700 ret
= SetThreadDesktop(old_thread_desk
);
701 ok(ret
, "SetThreadDesktop failed!\n");
702 thread_desk
= GetThreadDesktop(GetCurrentThreadId());
703 ok(thread_desk
== old_thread_desk
, "thread desktop doesn't match!\n");
704 memset(name
, 0, sizeof(name
));
705 ret
= GetUserObjectInformationA(thread_desk
, UOI_NAME
, name
, 1024, NULL
);
706 ok(!strcmp(name
, "Default"), "unexpected desktop %s\n", name
);
708 SetLastError(0xdeadbeef);
709 ret
= SendInput(1, inputs
, sizeof(INPUT
));
710 ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError());
711 ok(ret
== 1, "unexpected return count %d\n", ret
);
714 ret
= CloseDesktop(input_desk
);
715 ok(ret
, "CloseDesktop failed!\n");
716 ret
= CloseDesktop(old_input_desk
);
717 ok(ret
, "CloseDesktop failed!\n");
718 ret
= CloseDesktop(new_desk
);
719 ok(ret
, "CloseDesktop failed!\n");
722 static void test_inputdesktop2(void)
725 HDESK thread_desk
, new_desk
, input_desk
, hdesk
;
728 thread_desk
= GetThreadDesktop(GetCurrentThreadId());
729 ok(thread_desk
!= NULL
, "GetThreadDesktop failed!\n");
730 w1
= GetProcessWindowStation();
731 ok(w1
!= NULL
, "GetProcessWindowStation failed!\n");
732 SetLastError(0xdeadbeef);
733 w2
= CreateWindowStationA("winsta_test", 0, WINSTA_ALL_ACCESS
, NULL
);
734 ret
= GetLastError();
735 ok(w2
!= NULL
|| ret
== ERROR_ACCESS_DENIED
, "CreateWindowStation failed (%u)\n", ret
);
738 win_skip("Not enough privileges for CreateWindowStation\n");
742 ret
= EnumDesktopsA(GetProcessWindowStation(), desktop_callbackA
, 0);
743 ok(!ret
, "EnumDesktopsA failed!\n");
744 input_desk
= OpenInputDesktop(0, FALSE
, DESKTOP_ALL_ACCESS
);
745 ok(input_desk
!= NULL
, "OpenInputDesktop failed!\n");
746 ret
= CloseDesktop(input_desk
);
747 ok(ret
, "CloseDesktop failed!\n");
749 ret
= SetProcessWindowStation(w2
);
750 ok(ret
, "SetProcessWindowStation failed!\n");
751 hdesk
= GetThreadDesktop(GetCurrentThreadId());
752 ok(hdesk
!= NULL
, "GetThreadDesktop failed!\n");
753 ok(hdesk
== thread_desk
, "thread desktop should not change after winstation changed!\n");
754 ret
= EnumDesktopsA(GetProcessWindowStation(), desktop_callbackA
, 0);
756 new_desk
= CreateDesktopA("desk_test", NULL
, NULL
, 0, DESKTOP_ALL_ACCESS
, NULL
);
757 ok(new_desk
!= NULL
, "CreateDesktop failed!\n");
758 ret
= EnumDesktopsA(GetProcessWindowStation(), desktop_callbackA
, 0);
759 ok(!ret
, "EnumDesktopsA failed!\n");
760 SetLastError(0xdeadbeef);
761 input_desk
= OpenInputDesktop(0, FALSE
, DESKTOP_ALL_ACCESS
);
762 ok(input_desk
== NULL
, "OpenInputDesktop should fail on non default winstation!\n");
763 ok(GetLastError() == ERROR_INVALID_FUNCTION
|| broken(GetLastError() == 0xdeadbeef), "last error %08x\n", GetLastError());
765 hdesk
= OpenDesktopA("desk_test", 0, TRUE
, DESKTOP_ALL_ACCESS
);
766 ok(hdesk
!= NULL
, "OpenDesktop failed!\n");
767 SetLastError(0xdeadbeef);
768 ret
= SwitchDesktop(hdesk
);
770 ok(!ret
, "Switch to desktop belong to non default winstation should fail!\n");
772 ok(GetLastError() == ERROR_ACCESS_DENIED
|| broken(GetLastError() == 0xdeadbeef), "last error %08x\n", GetLastError());
773 ret
= SetThreadDesktop(hdesk
);
774 ok(ret
, "SetThreadDesktop failed!\n");
776 /* clean side effect */
777 ret
= SetThreadDesktop(thread_desk
);
779 ok(ret
, "SetThreadDesktop should success even desktop is not belong to process winstation!\n");
780 ret
= SetProcessWindowStation(w1
);
781 ok(ret
, "SetProcessWindowStation failed!\n");
782 ret
= SetThreadDesktop(thread_desk
);
783 ok(ret
, "SetThreadDesktop failed!\n");
784 ret
= CloseWindowStation(w2
);
785 ok(ret
, "CloseWindowStation failed!\n");
786 ret
= CloseDesktop(new_desk
);
787 ok(ret
, "CloseDesktop failed!\n");
788 ret
= CloseDesktop(hdesk
);
789 ok(ret
, "CloseDesktop failed!\n");
792 static LRESULT CALLBACK
WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
794 if (msg
== WM_DESTROY
)
796 trace("destroying hwnd %p\n", hWnd
);
800 return DefWindowProcA( hWnd
, msg
, wParam
, lParam
);
803 typedef struct tag_wnd_param
805 const char *wnd_name
;
811 static DWORD WINAPI
create_window(LPVOID param
)
813 wnd_param
*param1
= param
;
817 ret
= SetThreadDesktop(param1
->hdesk
);
818 ok(ret
, "SetThreadDesktop failed!\n");
819 param1
->hwnd
= CreateWindowA("test_class", param1
->wnd_name
, WS_POPUP
, 0, 0, 100, 100, NULL
, NULL
, NULL
, NULL
);
820 ok(param1
->hwnd
!= 0, "CreateWindowA failed!\n");
821 ret
= SetEvent(param1
->hevent
);
822 ok(ret
, "SetEvent failed!\n");
824 while (GetMessageA(&msg
, 0, 0, 0))
826 TranslateMessage(&msg
);
827 DispatchMessageA(&msg
);
833 static DWORD
set_foreground(HWND hwnd
)
836 DWORD set_id
, fore_id
, ret
;
839 hwnd_fore
= GetForegroundWindow();
840 GetWindowTextA(hwnd_fore
, win_text
, 1024);
841 set_id
= GetWindowThreadProcessId(hwnd
, NULL
);
842 fore_id
= GetWindowThreadProcessId(hwnd_fore
, NULL
);
843 trace("\"%s\" %p %08x hwnd %p %08x\n", win_text
, hwnd_fore
, fore_id
, hwnd
, set_id
);
844 ret
= AttachThreadInput(set_id
, fore_id
, TRUE
);
845 trace("AttachThreadInput returned %08x\n", ret
);
846 ret
= ShowWindow(hwnd
, SW_SHOWNORMAL
);
847 trace("ShowWindow returned %08x\n", ret
);
848 ret
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
);
849 trace("set topmost returned %08x\n", ret
);
850 ret
= SetWindowPos(hwnd
, HWND_NOTOPMOST
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
);
851 trace("set notopmost returned %08x\n", ret
);
852 ret
= SetForegroundWindow(hwnd
);
853 trace("SetForegroundWindow returned %08x\n", ret
);
855 AttachThreadInput(set_id
, fore_id
, FALSE
);
859 static void test_foregroundwindow(void)
861 HWND hwnd
, hwnd_test
, partners
[2], hwnds
[2];
863 int thread_desk_id
, input_desk_id
, hwnd_id
;
866 DWORD ret
, timeout
, timeout_old
;
871 memset( &wclass
, 0, sizeof(wclass
) );
872 wclass
.lpszClassName
= "test_class";
873 wclass
.lpfnWndProc
= WndProc
;
874 RegisterClassA(&wclass
);
875 param
.wnd_name
= "win_name";
877 hdesks
[0] = GetThreadDesktop(GetCurrentThreadId());
878 ok(hdesks
[0] != NULL
, "OpenDesktop failed!\n");
879 SetLastError(0xdeadbeef);
880 hdesks
[1] = CreateDesktopA("desk2", NULL
, NULL
, 0, DESKTOP_ALL_ACCESS
, NULL
);
881 ret
= GetLastError();
882 ok(hdesks
[1] != NULL
|| ret
== ERROR_ACCESS_DENIED
, "CreateDesktop failed (%u)\n", ret
);
885 win_skip("Not enough privileges for CreateDesktop\n");
889 ret
= SystemParametersInfoA(SPI_GETFOREGROUNDLOCKTIMEOUT
, 0, &timeout_old
, 0);
892 win_skip("Skip tests on NT4\n");
893 CloseDesktop(hdesks
[1]);
896 trace("old timeout %d\n", timeout_old
);
898 ret
= SystemParametersInfoA(SPI_SETFOREGROUNDLOCKTIMEOUT
, 0, 0, SPIF_SENDCHANGE
| SPIF_UPDATEINIFILE
);
899 ok(ret
, "set foreground lock timeout failed!\n");
900 ret
= SystemParametersInfoA(SPI_GETFOREGROUNDLOCKTIMEOUT
, 0, &timeout
, 0);
901 ok(ret
, "get foreground lock timeout failed!\n");
902 ok(timeout
== 0, "unexpected timeout %d\n", timeout
);
904 for (thread_desk_id
= 0; thread_desk_id
< DESKTOPS
; thread_desk_id
++)
906 param
.hdesk
= hdesks
[thread_desk_id
];
907 param
.hevent
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
908 CreateThread(NULL
, 0, create_window
, ¶m
, 0, NULL
);
909 ret
= WaitForSingleObject(param
.hevent
, INFINITE
);
910 ok(ret
== WAIT_OBJECT_0
, "wait failed!\n");
911 hwnds
[thread_desk_id
] = param
.hwnd
;
914 for (thread_desk_id
= 0; thread_desk_id
< DESKTOPS
; thread_desk_id
++)
916 param
.hdesk
= hdesks
[thread_desk_id
];
917 param
.hevent
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
918 CreateThread(NULL
, 0, create_window
, ¶m
, 0, NULL
);
919 ret
= WaitForSingleObject(param
.hevent
, INFINITE
);
920 ok(ret
== WAIT_OBJECT_0
, "wait failed!\n");
921 partners
[thread_desk_id
] = param
.hwnd
;
924 trace("hwnd0 %p hwnd1 %p partner0 %p partner1 %p\n", hwnds
[0], hwnds
[1], partners
[0], partners
[1]);
926 for (hwnd_id
= 0; hwnd_id
< DESKTOPS
; hwnd_id
++)
927 for (thread_desk_id
= 0; thread_desk_id
< DESKTOPS
; thread_desk_id
++)
928 for (input_desk_id
= 0; input_desk_id
< DESKTOPS
; input_desk_id
++)
930 trace("testing thread_desk %d input_desk %d hwnd %d\n",
931 thread_desk_id
, input_desk_id
, hwnd_id
);
932 hwnd_test
= hwnds
[hwnd_id
];
933 ret
= SetThreadDesktop(hdesks
[thread_desk_id
]);
934 ok(ret
, "set thread desktop failed!\n");
935 ret
= SwitchDesktop(hdesks
[input_desk_id
]);
936 ok(ret
, "switch desktop failed!\n");
937 set_foreground(partners
[0]);
938 set_foreground(partners
[1]);
939 hwnd
= GetForegroundWindow();
940 ok(hwnd
!= hwnd_test
, "unexpected foreground window %p\n", hwnd
);
941 ret
= set_foreground(hwnd_test
);
942 hwnd
= GetForegroundWindow();
943 GetWindowTextA(hwnd
, win_text
, 1024);
944 trace("hwnd %p name %s\n", hwnd
, win_text
);
945 if (input_desk_id
== hwnd_id
)
947 if (input_desk_id
== thread_desk_id
)
949 ok(ret
, "SetForegroundWindow failed!\n");
951 ok(hwnd
== hwnd_test
, "unexpected foreground window %p\n", hwnd
);
955 todo_wine
ok(ret
, "SetForegroundWindow failed!\n");
956 todo_wine
ok(hwnd
== 0, "unexpected foreground window %p\n", hwnd
);
961 if (input_desk_id
== thread_desk_id
)
963 ok(!ret
, "SetForegroundWindow should fail!\n");
965 ok(hwnd
== partners
[input_desk_id
] , "unexpected foreground window %p\n", hwnd
);
969 todo_wine
ok(!ret
, "SetForegroundWindow should fail!\n");
971 ok(hwnd
== 0, "unexpected foreground window %p\n", hwnd
);
978 for (thread_desk_id
= DESKTOPS
- 1; thread_desk_id
>= 0; thread_desk_id
--)
980 ret
= SetThreadDesktop(hdesks
[thread_desk_id
]);
981 ok(ret
, "set thread desktop failed!\n");
982 SendMessageA(hwnds
[thread_desk_id
], WM_DESTROY
, 0, 0);
983 SendMessageA(partners
[thread_desk_id
], WM_DESTROY
, 0, 0);
986 ret
= SwitchDesktop(hdesks
[0]);
987 ok(ret
, "switch desktop failed!\n");
988 CloseDesktop(hdesks
[1]);
990 ret
= SystemParametersInfoA(SPI_SETFOREGROUNDLOCKTIMEOUT
, 0, UlongToPtr(timeout_old
), SPIF_SENDCHANGE
| SPIF_UPDATEINIFILE
);
991 ok(ret
, "set foreground lock timeout failed!\n");
992 ret
= SystemParametersInfoA(SPI_GETFOREGROUNDLOCKTIMEOUT
, 0, &timeout
, 0);
993 ok(ret
, "get foreground lock timeout failed!\n");
994 ok(timeout
== timeout_old
, "unexpected timeout %d\n", timeout
);
997 START_TEST(winstation
)
999 HMODULE hntdll
= GetModuleHandleA("ntdll.dll");
1000 pNtQueryObject
= (void *)GetProcAddress(hntdll
, "NtQueryObject");
1002 /* Check whether this platform supports WindowStation calls */
1004 SetLastError( 0xdeadbeef );
1005 GetProcessWindowStation();
1006 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1008 win_skip("WindowStation calls not supported on this platform\n");
1012 test_inputdesktop();
1013 test_inputdesktop2();
1014 test_enumstations();
1015 test_enumdesktops();
1017 test_getuserobjectinformation();
1018 test_foregroundwindow();