1 /* Unit test suite for functions SystemParametersInfo and GetSystemMetrics.
3 * Copyright 2002 Andriy Palamarchuk
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define _WIN32_WINNT 0x0500 /* For SPI_GETMOUSEHOVERWIDTH and more */
27 #include "wine/test.h"
33 #ifndef SPI_GETDESKWALLPAPER
34 # define SPI_GETDESKWALLPAPER 0x0073
39 #define eq(received, expected, label, type) \
40 ok((received) == (expected), "%s: got " type " instead of " type "\n", (label),(received),(expected))
43 #define SPI_SETBEEP_REGKEY "Control Panel\\Sound"
44 #define SPI_SETBEEP_VALNAME "Beep"
45 #define SPI_SETMOUSE_REGKEY "Control Panel\\Mouse"
46 #define SPI_SETMOUSE_VALNAME1 "MouseThreshold1"
47 #define SPI_SETMOUSE_VALNAME2 "MouseThreshold2"
48 #define SPI_SETMOUSE_VALNAME3 "MouseSpeed"
49 #define SPI_SETBORDER_REGKEY "Control Panel\\Desktop\\WindowMetrics"
50 #define SPI_SETBORDER_VALNAME "BorderWidth"
51 #define SPI_SETKEYBOARDSPEED_REGKEY "Control Panel\\Keyboard"
52 #define SPI_SETKEYBOARDSPEED_VALNAME "KeyboardSpeed"
53 #define SPI_SETSCREENSAVETIMEOUT_REGKEY "Control Panel\\Desktop"
54 #define SPI_SETSCREENSAVETIMEOUT_VALNAME "ScreenSaveTimeOut"
55 #define SPI_SETSCREENSAVEACTIVE_REGKEY "Control Panel\\Desktop"
56 #define SPI_SETSCREENSAVEACTIVE_VALNAME "ScreenSaveActive"
57 #define SPI_SETGRIDGRANULARITY_REGKEY "Control Panel\\Desktop"
58 #define SPI_SETGRIDGRANULARITY_VALNAME "GridGranularity"
59 #define SPI_SETKEYBOARDDELAY_REGKEY "Control Panel\\Keyboard"
60 #define SPI_SETKEYBOARDDELAY_VALNAME "KeyboardDelay"
61 #define SPI_SETICONTITLEWRAP_REGKEY1 "Control Panel\\Desktop\\WindowMetrics"
62 #define SPI_SETICONTITLEWRAP_REGKEY2 "Control Panel\\Desktop"
63 #define SPI_SETICONTITLEWRAP_VALNAME "IconTitleWrap"
64 #define SPI_SETMENUDROPALIGNMENT_REGKEY1 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
65 #define SPI_SETMENUDROPALIGNMENT_REGKEY2 "Control Panel\\Desktop"
66 #define SPI_SETMENUDROPALIGNMENT_VALNAME "MenuDropAlignment"
67 #define SPI_SETDOUBLECLKWIDTH_REGKEY1 "Control Panel\\Mouse"
68 #define SPI_SETDOUBLECLKWIDTH_REGKEY2 "Control Panel\\Desktop"
69 #define SPI_SETDOUBLECLKWIDTH_VALNAME "DoubleClickWidth"
70 #define SPI_SETDOUBLECLKHEIGHT_REGKEY1 "Control Panel\\Mouse"
71 #define SPI_SETDOUBLECLKHEIGHT_REGKEY2 "Control Panel\\Desktop"
72 #define SPI_SETDOUBLECLKHEIGHT_VALNAME "DoubleClickHeight"
73 #define SPI_SETDOUBLECLICKTIME_REGKEY "Control Panel\\Mouse"
74 #define SPI_SETDOUBLECLICKTIME_VALNAME "DoubleClickSpeed"
75 #define SPI_SETMOUSEBUTTONSWAP_REGKEY "Control Panel\\Mouse"
76 #define SPI_SETMOUSEBUTTONSWAP_VALNAME "SwapMouseButtons"
77 #define SPI_SETWORKAREA_REGKEY "Control Panel\\Desktop"
78 #define SPI_SETWORKAREA_VALNAME "WINE_WorkArea"
79 #define SPI_SETSHOWSOUNDS_REGKEY "Control Panel\\Accessibility\\ShowSounds"
80 #define SPI_SETSHOWSOUNDS_VALNAME "On"
81 #define SPI_SETDRAGFULLWINDOWS_REGKEY "Control Panel\\Desktop"
82 #define SPI_SETDRAGFULLWINDOWS_VALNAME "DragFullWindows"
83 #define SPI_SETMOUSEHOVERWIDTH_REGKEY "Control Panel\\Mouse"
84 #define SPI_SETMOUSEHOVERWIDTH_VALNAME "MouseHoverWidth"
85 #define SPI_SETMOUSEHOVERHEIGHT_REGKEY "Control Panel\\Mouse"
86 #define SPI_SETMOUSEHOVERHEIGHT_VALNAME "MouseHoverHeight"
87 #define SPI_SETMOUSEHOVERTIME_REGKEY "Control Panel\\Mouse"
88 #define SPI_SETMOUSEHOVERTIME_VALNAME "MouseHoverTime"
89 #define SPI_SETMOUSESCROLLLINES_REGKEY "Control Panel\\Desktop"
90 #define SPI_SETMOUSESCROLLLINES_VALNAME "WheelScrollLines"
91 #define SPI_SETMENUSHOWDELAY_REGKEY "Control Panel\\Desktop"
92 #define SPI_SETMENUSHOWDELAY_VALNAME "MenuShowDelay"
93 #define SPI_SETDESKWALLPAPER_REGKEY "Control Panel\\Desktop"
94 #define SPI_SETDESKWALLPAPER_VALNAME "Wallpaper"
95 /* FIXME - don't have access to Windows with this action (W95, NT5.0). Set real values */
96 #define SPI_SETKEYBOARDPREF_REGKEY "Control Panel\\Desktop"
97 #define SPI_SETKEYBOARDPREF_VALNAME "WINE_WorkArea"
98 #define SPI_SETSCREENREADER_REGKEY "Control Panel\\Desktop"
99 #define SPI_SETSCREENREADER_VALNAME "???"
101 /* volatile registry branch under CURRENT_USER_REGKEY for temporary values storage */
102 #define WINE_CURRENT_USER_REGKEY "Wine"
104 static HWND ghTestWnd;
106 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam );
107 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
109 static int change_counter;
110 static int change_last_param;
112 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
117 case WM_SETTINGCHANGE:
118 if (change_counter>0) {
119 ok(0,"too many changes counter=%d last change=%d\n",
120 change_counter,change_last_param);
123 change_last_param = wParam;
127 PostQuitMessage( 0 );
131 return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
138 Performs testing for system parameters messages
140 - system parameter id
141 - supposed value of the registry key
143 static void test_change_message( int action, int optional )
145 if (change_counter==0 && optional==1)
147 ok( 1 == change_counter,
148 "Missed a message: change_counter=%d\n", change_counter );
150 ok( action == change_last_param,
151 "Wrong action got %d expected %d\n", change_last_param, action );
152 change_last_param = 0;
156 * Tests the HKEY_CURRENT_USER subkey value.
157 * The value should contain string value.
160 * lpsSubKey - subkey name
161 * lpsRegName - registry entry name
162 * lpsTestValue - value to test
164 static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName, LPCSTR testValue )
166 CHAR value[MAX_PATH];
174 valueLen=sizeof(value);
175 RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey );
176 rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
178 if (rc==ERROR_SUCCESS)
180 ok( !strcmp( testValue, value ),
181 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
182 subKey1, valName, testValue, value );
187 ok(0,"Missing registry entry: subKey=%s, valName=%s\n",
190 if (subKey2 && !strict)
193 valueLen=sizeof(value);
194 RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey );
195 rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
197 if (rc==ERROR_SUCCESS)
199 ok( !strcmp( testValue, value ),
200 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
201 subKey2, valName, testValue, value );
205 ok(found,"Missing registry entry: %s in %s or %s\n",
206 valName, subKey1, (subKey2?subKey2:"<n/a>") );
209 #define test_reg_key( subKey, valName, testValue ) \
210 _test_reg_key( subKey, NULL, valName, testValue )
211 #define test_reg_key_ex( subKey1, subKey2, valName, testValue ) \
212 _test_reg_key( subKey1, subKey2, valName, testValue )
214 static void test_SPI_SETBEEP( void ) /* 2 */
221 trace("testing SPI_{GET,SET}BEEP\n");
222 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &old_b, 0 );
223 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
226 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
227 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
228 test_change_message( SPI_SETBEEP, 0 );
229 test_reg_key( SPI_SETBEEP_REGKEY,
231 curr_val ? "Yes" : "No" );
232 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
233 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
234 eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
235 rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
236 if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
238 ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
239 eq( b, curr_val, "SystemParametersInfoW", "%d" );
242 /* is a message sent for the second change? */
243 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
244 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
245 test_change_message( SPI_SETBEEP, 0 );
248 rc=SystemParametersInfoW( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
249 if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
250 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
251 ok(rc!=0,"SystemParametersInfo: rc=%d err=%ld\n",rc,GetLastError());
252 test_change_message( SPI_SETBEEP, 0 );
253 test_reg_key( SPI_SETBEEP_REGKEY,
255 curr_val ? "Yes" : "No" );
256 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
257 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
258 eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
259 rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
260 if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
262 ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
263 eq( b, curr_val, "SystemParametersInfoW", "%d" );
265 ok( MessageBeep( MB_OK ), "Return value of MessageBeep when sound is disabled\n" );
267 rc=SystemParametersInfoA( SPI_SETBEEP, old_b, 0, SPIF_UPDATEINIFILE );
268 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
271 static const char *setmouse_valuenames[3] = {
272 SPI_SETMOUSE_VALNAME1,
273 SPI_SETMOUSE_VALNAME2,
274 SPI_SETMOUSE_VALNAME3
278 * Runs check for one setting of spi_setmouse.
280 static void run_spi_setmouse_test( int curr_val[], POINT *req_change, POINT *proj_change,
285 static int aw_turn = 0;
292 if (aw_turn % 2!=0) /* call unicode version each second call */
293 rc=SystemParametersInfoW( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
294 if (aw_turn % 2==0 || (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED))
295 rc=SystemParametersInfoA( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
296 ok(rc!=0,"SystemParametersInfo: rc=%d err=%ld\n",rc,GetLastError());
297 test_change_message( SPI_SETMOUSE, 0 );
298 for (i = 0; i < 3; i++)
300 sprintf( buf, "%d", curr_val[i] );
301 test_reg_key( SPI_SETMOUSE_REGKEY, setmouse_valuenames[i], buf );
304 rc=SystemParametersInfoA( SPI_GETMOUSE, 0, mi, 0 );
305 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
306 for (i = 0; i < 3; i++)
308 ok(mi[i] == curr_val[i],
309 "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
312 rc=SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 );
313 if (rc!=0 && GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
315 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
316 for (i = 0; i < 3; i++)
318 ok(mi[i] == curr_val[i],
319 "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
323 #if 0 /* FIXME: this always fails for me - AJ */
324 for (i = 0; i < nchange; i++)
327 mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 0, 0, 0 );
328 mouse_event( MOUSEEVENTF_MOVE, req_change[i].x, req_change[i].y, 0, 0 );
330 ok( proj_change[i].x == mv.x, "Projected dx and real dx comparison. May fail under high load.\n" );
331 ok( proj_change[i].y == mv.y, "Projected dy equals real dy. May fail under high load.\n" );
336 static void test_SPI_SETMOUSE( void ) /* 4 */
341 /* win nt default values - 6, 10, 1 */
342 INT curr_val[3] = {6, 10, 1};
344 /* requested and projected mouse movements */
345 POINT req_change[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
346 POINT proj_change1[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
347 POINT proj_change2[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {44, 20}, {400, 400} };
348 POINT proj_change3[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
349 POINT proj_change4[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
350 POINT proj_change5[] = { {6, 6}, { 7, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
351 POINT proj_change6[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
352 POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
353 POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
355 int nchange = sizeof( req_change ) / sizeof( POINT );
357 trace("testing SPI_{GET,SET}MOUSE\n");
358 rc=SystemParametersInfoA( SPI_GETMOUSE, 0, old_mi, 0 );
359 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
361 run_spi_setmouse_test( curr_val, req_change, proj_change1, nchange );
363 /* acceleration change */
365 run_spi_setmouse_test( curr_val, req_change, proj_change2, nchange );
367 /* acceleration change */
369 run_spi_setmouse_test( curr_val, req_change, proj_change3, nchange );
371 /* acceleration change */
373 run_spi_setmouse_test( curr_val, req_change, proj_change4, nchange );
375 /* threshold change */
378 run_spi_setmouse_test( curr_val, req_change, proj_change5, nchange );
380 /* threshold change */
384 run_spi_setmouse_test( curr_val, req_change, proj_change6, nchange );
386 /* threshold change */
388 run_spi_setmouse_test( curr_val, req_change, proj_change7, nchange );
390 /* threshold change */
392 run_spi_setmouse_test( curr_val, req_change, proj_change8, nchange );
394 rc=SystemParametersInfoA( SPI_SETMOUSE, 0, old_mi, SPIF_UPDATEINIFILE );
395 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
399 static void test_setborder(UINT curr_val)
406 rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
407 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
408 test_change_message( SPI_SETBORDER, 1 );
409 sprintf( buf, "%d", curr_val );
410 test_reg_key( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, buf );
414 rc=SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 );
415 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
416 eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d");
418 frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME );
419 eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" );
420 eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" );
421 eq( frame, GetSystemMetrics( SM_CXSIZEFRAME ), "SM_CXSIZEFRAME", "%d" );
422 eq( frame, GetSystemMetrics( SM_CYSIZEFRAME ), "SM_CYSIZEFRAME", "%d" );
425 static void test_SPI_SETBORDER( void ) /* 6 */
430 /* These tests hang when XFree86 4.0 for Windows is running (tested on
431 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
434 if (FindWindowA( NULL, "Cygwin/XFree86" ))
437 trace("testing SPI_{GET,SET}BORDER\n");
438 rc=SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 );
439 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
446 /* This will restore sane values if the test hang previous run. */
447 if ( old_border == 7 || old_border == 20 )
450 rc=SystemParametersInfoA( SPI_SETBORDER, old_border, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
451 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
455 static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */
459 const UINT vals[]={0,20,31};
462 trace("testing SPI_{GET,SET}KEYBOARDSPEED\n");
463 rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &old_speed, 0 );
464 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
466 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
471 rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, vals[i], 0,
472 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
473 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
474 test_change_message( SPI_SETKEYBOARDSPEED, 0 );
475 sprintf( buf, "%d", vals[i] );
476 test_reg_key( SPI_SETKEYBOARDSPEED_REGKEY, SPI_SETKEYBOARDSPEED_VALNAME, buf );
478 rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &v, 0 );
479 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
480 eq( v, vals[i], "SPI_{GET,SET}KEYBOARDSPEED", "%d" );
483 rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, old_speed, 0, SPIF_UPDATEINIFILE );
484 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
487 static void test_SPI_ICONHORIZONTALSPACING( void ) /* 13 */
494 trace("testing SPI_ICONHORIZONTALSPACING\n");
495 /* default value: 75 */
496 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &old_spacing, 0 );
497 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
499 /* do not increase the value as it would upset the user's icon layout */
500 curr_val = (old_spacing > 32 ? old_spacing-1 : 32);
501 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
502 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
503 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
504 test_change_message( SPI_ICONHORIZONTALSPACING, 0 );
505 /* The registry keys depend on the Windows version and the values too
509 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
510 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
511 eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d");
512 eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
515 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
516 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
517 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
518 curr_val = 32; /*min value*/
519 test_change_message( SPI_ICONHORIZONTALSPACING, 0 );
521 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
522 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
523 eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d" );
524 eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
526 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, old_spacing, 0, SPIF_UPDATEINIFILE );
527 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
530 static void test_SPI_SETSCREENSAVETIMEOUT( void ) /* 14 */
534 const UINT vals[]={0,32767};
537 trace("testing SPI_{GET,SET}SCREENSAVETIMEOUT\n");
538 rc=SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &old_timeout, 0 );
539 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
541 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
546 rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, vals[i], 0,
547 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
548 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
549 test_change_message( SPI_SETSCREENSAVETIMEOUT, 0 );
550 sprintf( buf, "%d", vals[i] );
551 test_reg_key( SPI_SETSCREENSAVETIMEOUT_REGKEY,
552 SPI_SETSCREENSAVETIMEOUT_VALNAME, buf );
554 SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &v, 0 );
555 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
556 eq( v, vals[i], "SPI_{GET,SET}SCREENSAVETIMEOUT", "%d" );
559 rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, old_timeout, 0,
560 SPIF_UPDATEINIFILE );
561 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
564 static void test_SPI_SETSCREENSAVEACTIVE( void ) /* 17 */
568 const UINT vals[]={TRUE,FALSE};
571 trace("testing SPI_{GET,SET}SCREENSAVEACTIVE\n");
572 rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &old_b, 0 );
573 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
575 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
579 rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, vals[i], 0,
580 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
581 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
582 test_change_message( SPI_SETSCREENSAVEACTIVE, 0 );
583 test_reg_key( SPI_SETSCREENSAVEACTIVE_REGKEY,
584 SPI_SETSCREENSAVEACTIVE_VALNAME,
585 vals[i] ? "1" : "0" );
587 rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &v, 0 );
588 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
589 eq( v, vals[i], "SPI_{GET,SET}SCREENSAVEACTIVE", "%d" );
592 rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
593 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
596 static void test_SPI_SETGRIDGRANULARITY( void ) /* 19 */
601 static void test_SPI_SETKEYBOARDDELAY( void ) /* 23 */
605 const UINT vals[]={0,3};
608 trace("testing SPI_{GET,SET}KEYBOARDDELAY\n");
609 rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &old_delay, 0 );
610 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
612 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
617 rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, vals[i], 0,
618 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
619 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
620 test_change_message( SPI_SETKEYBOARDDELAY, 0 );
621 sprintf( buf, "%d", vals[i] );
622 test_reg_key( SPI_SETKEYBOARDDELAY_REGKEY,
623 SPI_SETKEYBOARDDELAY_VALNAME, buf );
625 rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &delay, 0 );
626 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
627 eq( delay, vals[i], "SPI_{GET,SET}KEYBOARDDELAY", "%d" );
630 rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, old_delay, 0, SPIF_UPDATEINIFILE );
631 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
634 static void test_SPI_ICONVERTICALSPACING( void ) /* 24 */
641 trace("testing SPI_ICONVERTICALSPACING\n");
642 /* default value: 75 */
643 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &old_spacing, 0 );
644 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
646 /* do not increase the value as it would upset the user's icon layout */
647 curr_val = old_spacing-1;
648 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
649 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
650 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
651 test_change_message( SPI_ICONVERTICALSPACING, 0 );
652 /* The registry keys depend on the Windows version and the values too
656 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
657 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
658 eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
659 eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
662 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
663 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
664 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
665 curr_val = 32; /*min value*/
666 test_change_message( SPI_ICONVERTICALSPACING, 0 );
668 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
669 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
670 eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
671 eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
673 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, old_spacing, 0,
674 SPIF_UPDATEINIFILE );
675 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
678 static void test_SPI_SETICONTITLEWRAP( void ) /* 26 */
682 const UINT vals[]={TRUE,FALSE};
685 /* These tests hang when XFree86 4.0 for Windows is running (tested on
686 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
689 if (FindWindowA( NULL, "Cygwin/XFree86" ))
692 trace("testing SPI_{GET,SET}ICONTITLEWRAP\n");
693 rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &old_b, 0 );
694 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
696 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
700 rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, vals[i], 0,
701 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
702 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
703 test_change_message( SPI_SETICONTITLEWRAP, 1 );
704 test_reg_key_ex( SPI_SETICONTITLEWRAP_REGKEY1,
705 SPI_SETICONTITLEWRAP_REGKEY2,
706 SPI_SETICONTITLEWRAP_VALNAME,
707 vals[i] ? "1" : "0" );
709 rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &v, 0 );
710 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
711 eq( v, vals[i], "SPI_{GET,SET}ICONTITLEWRAP", "%d" );
714 rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, old_b, 0, SPIF_UPDATEINIFILE );
715 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
718 static void test_SPI_SETMENUDROPALIGNMENT( void ) /* 28 */
722 const UINT vals[]={TRUE,FALSE};
725 trace("testing SPI_{GET,SET}MENUDROPALIGNMENT\n");
726 rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &old_b, 0 );
727 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
729 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
733 rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, vals[i], 0,
734 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
735 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
736 test_change_message( SPI_SETMENUDROPALIGNMENT, 0 );
737 test_reg_key_ex( SPI_SETMENUDROPALIGNMENT_REGKEY1,
738 SPI_SETMENUDROPALIGNMENT_REGKEY2,
739 SPI_SETMENUDROPALIGNMENT_VALNAME,
740 vals[i] ? "1" : "0" );
742 rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &v, 0 );
743 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
744 eq( v, vals[i], "SPI_{GET,SET}MENUDROPALIGNMENT", "%d" );
745 eq( GetSystemMetrics( SM_MENUDROPALIGNMENT ), (int)vals[i],
746 "SM_MENUDROPALIGNMENT", "%d" );
749 rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, old_b, 0,
750 SPIF_UPDATEINIFILE );
751 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
754 static void test_SPI_SETDOUBLECLKWIDTH( void ) /* 29 */
758 const UINT vals[]={0,10000};
761 trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n");
762 old_width = GetSystemMetrics( SM_CXDOUBLECLK );
764 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
768 rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, vals[i], 0,
769 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
770 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
771 test_change_message( SPI_SETDOUBLECLKWIDTH, 0 );
772 sprintf( buf, "%d", vals[i] );
773 test_reg_key_ex( SPI_SETDOUBLECLKWIDTH_REGKEY1,
774 SPI_SETDOUBLECLKWIDTH_REGKEY2,
775 SPI_SETDOUBLECLKWIDTH_VALNAME, buf );
776 eq( GetSystemMetrics( SM_CXDOUBLECLK ), (int)vals[i],
777 "SM_CXDOUBLECLK", "%d" );
780 rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, old_width, 0,
781 SPIF_UPDATEINIFILE );
782 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
785 static void test_SPI_SETDOUBLECLKHEIGHT( void ) /* 30 */
789 const UINT vals[]={0,10000};
792 trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n");
793 old_height = GetSystemMetrics( SM_CYDOUBLECLK );
795 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
799 rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, vals[i], 0,
800 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
801 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
802 test_change_message( SPI_SETDOUBLECLKHEIGHT, 0 );
803 sprintf( buf, "%d", vals[i] );
804 test_reg_key_ex( SPI_SETDOUBLECLKHEIGHT_REGKEY1,
805 SPI_SETDOUBLECLKHEIGHT_REGKEY2,
806 SPI_SETDOUBLECLKHEIGHT_VALNAME, buf );
807 eq( GetSystemMetrics( SM_CYDOUBLECLK ), (int)vals[i],
808 "SM_CYDOUBLECLK", "%d" );
811 rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, old_height, 0,
812 SPIF_UPDATEINIFILE );
813 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
816 static void test_SPI_SETDOUBLECLICKTIME( void ) /* 32 */
824 trace("testing SPI_{GET,SET}DOUBLECLICKTIME\n");
825 old_time = GetDoubleClickTime();
828 rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
829 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
830 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
831 test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
832 sprintf( buf, "%d", curr_val );
833 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
834 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
835 curr_val = 500; /* used value for 0 */
836 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
839 rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
840 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
841 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
842 test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
843 sprintf( buf, "%d", curr_val );
844 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
845 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
846 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
848 saved_val = curr_val;
851 SetDoubleClickTime( curr_val );
852 sprintf( buf, "%d", saved_val );
853 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
854 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
855 curr_val = 500; /* used value for 0 */
856 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
859 SetDoubleClickTime( curr_val );
860 sprintf( buf, "%d", saved_val );
861 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
862 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
863 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
865 rc=SystemParametersInfoA(SPI_SETDOUBLECLICKTIME, old_time, 0, SPIF_UPDATEINIFILE);
866 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
869 static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
873 const UINT vals[]={TRUE,FALSE};
876 trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
877 old_b = GetSystemMetrics( SM_SWAPBUTTON );
879 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
881 rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0,
882 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
883 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
884 test_change_message( SPI_SETMOUSEBUTTONSWAP, 0 );
885 test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY,
886 SPI_SETMOUSEBUTTONSWAP_VALNAME,
887 vals[i] ? "1" : "0" );
888 eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i],
889 "SM_SWAPBUTTON", "%d" );
892 rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0,
893 SPIF_UPDATEINIFILE );
894 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
897 static void test_SPI_SETFASTTASKSWITCH( void ) /* 36 */
902 trace("testing SPI_GETFASTTASKSWITCH\n");
903 rc=SystemParametersInfoA( SPI_GETFASTTASKSWITCH, 0, &v, 0 );
904 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
905 /* there is not a single Windows platform on which SPI_GETFASTTASKSWITCH
906 * works. That sure simplifies testing!
910 static void test_SPI_SETDRAGFULLWINDOWS( void ) /* 37 */
914 const UINT vals[]={TRUE,FALSE};
917 trace("testing SPI_{GET,SET}DRAGFULLWINDOWS\n");
918 rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &old_b, 0 );
919 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_CALL_NOT_IMPLEMENTED))
921 /* SPI_{GET,SET}DRAGFULLWINDOWS is not implemented on Win95 */
922 trace("SPI_{GET,SET}DRAGFULLWINDOWS not supported on this platform\n");
925 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
927 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
931 rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, vals[i], 0,
932 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
933 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
934 test_change_message( SPI_SETDRAGFULLWINDOWS, 0 );
935 test_reg_key( SPI_SETDRAGFULLWINDOWS_REGKEY,
936 SPI_SETDRAGFULLWINDOWS_VALNAME,
937 vals[i] ? "1" : "0" );
939 rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &v, 0 );
940 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
941 eq( v, vals[i], "SPI_{GET,SET}DRAGFULLWINDOWS", "%d" );
944 rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, old_b, 0, SPIF_UPDATEINIFILE );
945 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
948 static void test_SPI_SETWORKAREA( void ) /* 47 */
955 trace("testing SPI_{GET,SET}WORKAREA\n");
956 rc=SystemParametersInfoA(SPI_GETWORKAREA, 0, &old_area, 0);
957 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
959 /* Modify the work area only minimally as this causes the icons that
960 * fall outside it to be moved around thus requiring the user to
961 * reposition them manually one by one.
962 * Changing the work area by just one pixel should make this occurence
963 * reasonably unlikely.
965 curr_val.left = old_area.left;
966 curr_val.top = old_area.top;
967 curr_val.right = old_area.right-1;
968 curr_val.bottom = old_area.bottom-1;
969 rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &curr_val,
970 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
971 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
972 test_change_message( SPI_SETWORKAREA, 0 );
973 rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
974 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
975 eq( area.left, curr_val.left, "left", "%ld" );
976 eq( area.top, curr_val.top, "top", "%ld" );
977 eq( area.right, curr_val.right, "right", "%ld" );
978 eq( area.bottom, curr_val.bottom, "bottom", "%ld" );
980 rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &old_area,
981 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
982 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
983 test_change_message( SPI_SETWORKAREA, 0 );
984 rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
985 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
986 eq( area.left, old_area.left, "left", "%ld" );
987 eq( area.top, old_area.top, "top", "%ld" );
988 eq( area.right, old_area.right, "right", "%ld" );
989 eq( area.bottom, old_area.bottom, "bottom", "%ld" );
992 static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */
996 const UINT vals[]={TRUE,FALSE};
999 trace("testing SPI_{GET,SET}SHOWSOUNDS\n");
1001 rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &old_b, 0 );
1002 if (rc==0 && GetLastError()==0)
1004 /* SPI_{GET,SET}SHOWSOUNDS is completely broken on Win9x */
1005 trace("SPI_{GET,SET}SHOWSOUNDS not supported on this platform\n");
1008 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1010 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1014 rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, vals[i], 0,
1015 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1016 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1017 test_change_message( SPI_SETSHOWSOUNDS, 0 );
1018 test_reg_key( SPI_SETSHOWSOUNDS_REGKEY,
1019 SPI_SETSHOWSOUNDS_VALNAME,
1020 vals[i] ? "1" : "0" );
1022 rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &v, 0 );
1023 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1024 eq( v, vals[i], "SPI_GETSHOWSOUNDS", "%d" );
1025 eq( GetSystemMetrics( SM_SHOWSOUNDS ), (int)vals[i],
1026 "SM_SHOWSOUNDS", "%d" );
1029 rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, old_b, 0, SPIF_UPDATEINIFILE );
1030 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1033 static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
1035 /* TODO!!! - don't have version of Windows which has this */
1038 static void test_SPI_SETSCREENREADER( void ) /* 71 */
1040 /* TODO!!! - don't have version of Windows which has this */
1043 static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */
1047 const UINT vals[]={0,32767};
1050 trace("testing SPI_{GET,SET}MOUSEHOVERWIDTH\n");
1051 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH, 0, &old_width, 0 );
1052 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1054 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1055 * what MSDN states (Verified on Win98SE)
1057 trace("SPI_{GET,SET}MOUSEHOVERWIDTH not supported on this platform\n");
1060 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1062 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1067 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH, vals[i], 0,
1068 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1069 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1070 test_change_message( SPI_SETMOUSEHOVERWIDTH, 0 );
1071 sprintf( buf, "%d", vals[i] );
1072 test_reg_key( SPI_SETMOUSEHOVERWIDTH_REGKEY,
1073 SPI_SETMOUSEHOVERWIDTH_VALNAME, buf );
1075 SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH, 0, &v, 0 );
1076 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1077 eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERWIDTH", "%d" );
1080 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH, old_width, 0,
1081 SPIF_UPDATEINIFILE );
1082 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1085 static void test_SPI_SETMOUSEHOVERHEIGHT( void ) /* 101 */
1089 const UINT vals[]={0,32767};
1092 trace("testing SPI_{GET,SET}MOUSEHOVERHEIGHT\n");
1093 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT, 0, &old_height, 0 );
1094 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1096 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1097 * what MSDN states (Verified on Win98SE)
1099 trace("SPI_{GET,SET}MOUSEHOVERHEIGHT not supported on this platform\n");
1102 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1104 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1109 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT, vals[i], 0,
1110 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1111 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1112 test_change_message( SPI_SETMOUSEHOVERHEIGHT, 0 );
1113 sprintf( buf, "%d", vals[i] );
1114 test_reg_key( SPI_SETMOUSEHOVERHEIGHT_REGKEY,
1115 SPI_SETMOUSEHOVERHEIGHT_VALNAME, buf );
1117 SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT, 0, &v, 0 );
1118 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1119 eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERHEIGHT", "%d" );
1122 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT, old_height, 0,
1123 SPIF_UPDATEINIFILE );
1124 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1127 static void test_SPI_SETMOUSEHOVERTIME( void ) /* 103 */
1131 const UINT vals[]={0,32767};
1134 trace("testing SPI_{GET,SET}MOUSEHOVERTIME\n");
1135 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERTIME, 0, &old_time, 0 );
1136 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1138 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1139 * what MSDN states (Verified on Win98SE)
1141 trace("SPI_{GET,SET}MOUSEHOVERTIME not supported on this platform\n");
1144 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1146 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1151 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME, vals[i], 0,
1152 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1153 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1154 test_change_message( SPI_SETMOUSEHOVERTIME, 0 );
1155 sprintf( buf, "%d", vals[i] );
1156 test_reg_key( SPI_SETMOUSEHOVERTIME_REGKEY,
1157 SPI_SETMOUSEHOVERTIME_VALNAME, buf );
1159 SystemParametersInfoA( SPI_GETMOUSEHOVERTIME, 0, &v, 0 );
1160 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1161 eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERTIME", "%d" );
1164 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME, old_time, 0,
1165 SPIF_UPDATEINIFILE );
1166 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1169 static void test_SPI_SETWHEELSCROLLLINES( void ) /* 105 */
1173 const UINT vals[]={0,32767};
1176 trace("testing SPI_{GET,SET}WHEELSCROLLLINES\n");
1177 rc=SystemParametersInfoA( SPI_GETWHEELSCROLLLINES, 0, &old_lines, 0 );
1178 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1180 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1185 rc=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES, vals[i], 0,
1186 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1187 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1188 test_change_message( SPI_SETWHEELSCROLLLINES, 0 );
1189 sprintf( buf, "%d", vals[i] );
1190 test_reg_key( SPI_SETMOUSESCROLLLINES_REGKEY,
1191 SPI_SETMOUSESCROLLLINES_VALNAME, buf );
1193 SystemParametersInfoA( SPI_GETWHEELSCROLLLINES, 0, &v, 0 );
1194 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1195 eq( v, vals[i], "SPI_{GET,SET}MOUSESCROLLLINES", "%d" );
1198 rc=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES, old_lines, 0,
1199 SPIF_UPDATEINIFILE );
1200 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1203 static void test_SPI_SETMENUSHOWDELAY( void ) /* 107 */
1207 const UINT vals[]={0,32767};
1210 trace("testing SPI_{GET,SET}MENUSHOWDELAY\n");
1211 rc=SystemParametersInfoA( SPI_GETMENUSHOWDELAY, 0, &old_delay, 0 );
1212 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1214 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1219 rc=SystemParametersInfoA( SPI_SETMENUSHOWDELAY, vals[i], 0,
1220 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1221 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1222 test_change_message( SPI_SETMENUSHOWDELAY, 0 );
1223 sprintf( buf, "%d", vals[i] );
1224 test_reg_key( SPI_SETMENUSHOWDELAY_REGKEY,
1225 SPI_SETMENUSHOWDELAY_VALNAME, buf );
1227 SystemParametersInfoA( SPI_GETMENUSHOWDELAY, 0, &v, 0 );
1228 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1229 eq( v, vals[i], "SPI_{GET,SET}MENUSHOWDELAY", "%d" );
1232 rc=SystemParametersInfoA( SPI_SETMENUSHOWDELAY, old_delay, 0,
1233 SPIF_UPDATEINIFILE );
1234 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1237 static void test_SPI_SETWALLPAPER( void ) /* 115 */
1243 trace("testing SPI_{GET,SET}DESKWALLPAPER\n");
1245 rc=SystemParametersInfoA(SPI_GETDESKWALLPAPER, 260, oldval, 0);
1246 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1248 /* SPI_{GET,SET}DESKWALLPAPER is completely broken on Win9x and
1249 * unimplemented on NT4
1251 trace("SPI_{GET,SET}DESKWALLPAPER not supported on this platform\n");
1254 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1257 rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, newval, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
1258 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1259 test_change_message(SPI_SETDESKWALLPAPER, 0);
1261 rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, oldval, SPIF_UPDATEINIFILE);
1262 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1264 test_reg_key(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, oldval);
1268 * Registry entries for the system parameters.
1269 * Names are created by 'SET' flags names.
1270 * We assume that corresponding 'GET' entries use the same registry keys.
1272 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
1274 test_SPI_SETBEEP(); /* 1 */
1275 test_SPI_SETMOUSE(); /* 4 */
1276 /* Messes up systems settings on Win9x */
1277 /*test_SPI_SETBORDER();*/ /* 6 */
1278 test_SPI_SETKEYBOARDSPEED(); /* 10 */
1279 test_SPI_ICONHORIZONTALSPACING(); /* 13 */
1280 test_SPI_SETSCREENSAVETIMEOUT(); /* 14 */
1281 test_SPI_SETSCREENSAVEACTIVE(); /* 17 */
1282 test_SPI_SETGRIDGRANULARITY(); /* 19 */
1283 test_SPI_SETKEYBOARDDELAY(); /* 23 */
1284 test_SPI_ICONVERTICALSPACING(); /* 24 */
1285 test_SPI_SETICONTITLEWRAP(); /* 26 */
1286 test_SPI_SETMENUDROPALIGNMENT(); /* 28 */
1287 test_SPI_SETDOUBLECLKWIDTH(); /* 29 */
1288 test_SPI_SETDOUBLECLKHEIGHT(); /* 30 */
1289 test_SPI_SETDOUBLECLICKTIME(); /* 32 */
1290 test_SPI_SETMOUSEBUTTONSWAP(); /* 33 */
1291 test_SPI_SETFASTTASKSWITCH(); /* 36 */
1292 test_SPI_SETDRAGFULLWINDOWS(); /* 37 */
1293 test_SPI_SETWORKAREA(); /* 47 */
1294 test_SPI_SETSHOWSOUNDS(); /* 57 */
1295 test_SPI_SETKEYBOARDPREF(); /* 69 */
1296 test_SPI_SETSCREENREADER(); /* 71 */
1297 test_SPI_SETMOUSEHOVERWIDTH(); /* 99 */
1298 test_SPI_SETMOUSEHOVERHEIGHT(); /* 101 */
1299 test_SPI_SETMOUSEHOVERTIME(); /* 103 */
1300 test_SPI_SETWHEELSCROLLLINES(); /* 105 */
1301 test_SPI_SETMENUSHOWDELAY(); /* 107 */
1302 test_SPI_SETWALLPAPER(); /* 115 */
1303 SendMessageA( ghTestWnd, WM_DESTROY, 0, 0 );
1307 START_TEST(sysparams)
1315 HANDLE hInstance = GetModuleHandleA( NULL );
1317 /* This test requires interactivity, if we don't have it, give up */
1318 if (!SystemParametersInfoA( SPI_SETBEEP, TRUE, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ) &&
1319 GetLastError()==ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION) return;
1321 argc = winetest_get_mainargs(&argv);
1322 strict=(argc >= 3 && strcmp(argv[2],"strict")==0);
1323 trace("strict=%d\n",strict);
1326 change_last_param = 0;
1328 wc.lpszClassName = "SysParamsTestClass";
1329 wc.lpfnWndProc = SysParamsTestWndProc;
1330 wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
1331 wc.hInstance = hInstance;
1332 wc.hIcon = LoadIconA( 0, (LPSTR)IDI_APPLICATION );
1333 wc.hCursor = LoadCursorA( 0, (LPSTR)IDC_ARROW );
1334 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1 );
1335 wc.lpszMenuName = 0;
1338 RegisterClassA( &wc );
1340 ghTestWnd = CreateWindowA( "SysParamsTestClass", "Test System Parameters Application",
1341 WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, hInstance, NULL );
1343 hThread = CreateThread( NULL, 0, SysParamsThreadFunc, 0, 0, &dwThreadId );
1345 CloseHandle( hThread );
1347 while( GetMessageA( &msg, 0, 0, 0 )) {
1348 TranslateMessage( &msg );
1349 DispatchMessageA( &msg );