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 #include "wine/test.h"
31 #ifndef SPI_GETDESKWALLPAPER
32 # define SPI_GETDESKWALLPAPER 0x0073
37 #define eq(received, expected, label, type) \
38 ok((received) == (expected), "%s: got " type " instead of " type "\n", (label),(received),(expected))
41 #define SPI_SETBEEP_REGKEY "Control Panel\\Sound"
42 #define SPI_SETBEEP_VALNAME "Beep"
43 #define SPI_SETMOUSE_REGKEY "Control Panel\\Mouse"
44 #define SPI_SETMOUSE_VALNAME1 "MouseThreshold1"
45 #define SPI_SETMOUSE_VALNAME2 "MouseThreshold2"
46 #define SPI_SETMOUSE_VALNAME3 "MouseSpeed"
47 #define SPI_SETBORDER_REGKEY "Control Panel\\Desktop\\WindowMetrics"
48 #define SPI_SETBORDER_VALNAME "BorderWidth"
49 #define SPI_SETKEYBOARDSPEED_REGKEY "Control Panel\\Keyboard"
50 #define SPI_SETKEYBOARDSPEED_VALNAME "KeyboardSpeed"
51 #define SPI_SETSCREENSAVETIMEOUT_REGKEY "Control Panel\\Desktop"
52 #define SPI_SETSCREENSAVETIMEOUT_VALNAME "ScreenSaveTimeOut"
53 #define SPI_SETSCREENSAVEACTIVE_REGKEY "Control Panel\\Desktop"
54 #define SPI_SETSCREENSAVEACTIVE_VALNAME "ScreenSaveActive"
55 #define SPI_SETGRIDGRANULARITY_REGKEY "Control Panel\\Desktop"
56 #define SPI_SETGRIDGRANULARITY_VALNAME "GridGranularity"
57 #define SPI_SETKEYBOARDDELAY_REGKEY "Control Panel\\Keyboard"
58 #define SPI_SETKEYBOARDDELAY_VALNAME "KeyboardDelay"
59 #define SPI_SETICONTITLEWRAP_REGKEY1 "Control Panel\\Desktop\\WindowMetrics"
60 #define SPI_SETICONTITLEWRAP_REGKEY2 "Control Panel\\Desktop"
61 #define SPI_SETICONTITLEWRAP_VALNAME "IconTitleWrap"
62 #define SPI_SETMENUDROPALIGNMENT_REGKEY1 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
63 #define SPI_SETMENUDROPALIGNMENT_REGKEY2 "Control Panel\\Desktop"
64 #define SPI_SETMENUDROPALIGNMENT_VALNAME "MenuDropAlignment"
65 #define SPI_SETDOUBLECLKWIDTH_REGKEY1 "Control Panel\\Mouse"
66 #define SPI_SETDOUBLECLKWIDTH_REGKEY2 "Control Panel\\Desktop"
67 #define SPI_SETDOUBLECLKWIDTH_VALNAME "DoubleClickWidth"
68 #define SPI_SETDOUBLECLKHEIGHT_REGKEY1 "Control Panel\\Mouse"
69 #define SPI_SETDOUBLECLKHEIGHT_REGKEY2 "Control Panel\\Desktop"
70 #define SPI_SETDOUBLECLKHEIGHT_VALNAME "DoubleClickHeight"
71 #define SPI_SETDOUBLECLICKTIME_REGKEY "Control Panel\\Mouse"
72 #define SPI_SETDOUBLECLICKTIME_VALNAME "DoubleClickSpeed"
73 #define SPI_SETMOUSEBUTTONSWAP_REGKEY "Control Panel\\Mouse"
74 #define SPI_SETMOUSEBUTTONSWAP_VALNAME "SwapMouseButtons"
75 #define SPI_SETWORKAREA_REGKEY "Control Panel\\Desktop"
76 #define SPI_SETWORKAREA_VALNAME "WINE_WorkArea"
77 #define SPI_SETSHOWSOUNDS_REGKEY "Control Panel\\Accessibility\\ShowSounds"
78 #define SPI_SETSHOWSOUNDS_VALNAME "On"
79 #define SPI_SETDRAGFULLWINDOWS_REGKEY "Control Panel\\Desktop"
80 #define SPI_SETDRAGFULLWINDOWS_VALNAME "DragFullWindows"
81 #define SPI_SETMOUSEHOVERWIDTH_REGKEY "Control Panel\\Mouse"
82 #define SPI_SETMOUSEHOVERWIDTH_VALNAME "MouseHoverWidth"
83 #define SPI_SETMOUSEHOVERHEIGHT_REGKEY "Control Panel\\Mouse"
84 #define SPI_SETMOUSEHOVERHEIGHT_VALNAME "MouseHoverHeight"
85 #define SPI_SETMOUSEHOVERTIME_REGKEY "Control Panel\\Mouse"
86 #define SPI_SETMOUSEHOVERTIME_VALNAME "MouseHoverTime"
87 #define SPI_SETMOUSESCROLLLINES_REGKEY "Control Panel\\Desktop"
88 #define SPI_SETMOUSESCROLLLINES_VALNAME "WheelScrollLines"
89 #define SPI_SETMENUSHOWDELAY_REGKEY "Control Panel\\Desktop"
90 #define SPI_SETMENUSHOWDELAY_VALNAME "MenuShowDelay"
91 #define SPI_SETDESKWALLPAPER_REGKEY "Control Panel\\Desktop"
92 #define SPI_SETDESKWALLPAPER_VALNAME "Wallpaper"
93 /* FIXME - don't have access to Windows with this action (W95, NT5.0). Set real values */
94 #define SPI_SETKEYBOARDPREF_REGKEY "Control Panel\\Desktop"
95 #define SPI_SETKEYBOARDPREF_VALNAME "WINE_WorkArea"
96 #define SPI_SETSCREENREADER_REGKEY "Control Panel\\Desktop"
97 #define SPI_SETSCREENREADER_VALNAME "???"
99 /* volatile registry branch under CURRENT_USER_REGKEY for temporary values storage */
100 #define WINE_CURRENT_USER_REGKEY "Wine"
102 static HWND ghTestWnd;
104 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam );
105 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
107 static int change_counter;
108 static int change_last_param;
110 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
115 case WM_SETTINGCHANGE:
116 if (change_counter>0) {
117 ok(0,"too many changes counter=%d last change=%d\n",
118 change_counter,change_last_param);
121 change_last_param = wParam;
125 PostQuitMessage( 0 );
129 return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
136 Performs testing for system parameters messages
138 - system parameter id
139 - supposed value of the registry key
141 static void test_change_message( int action, int optional )
143 if (change_counter==0 && optional==1)
145 ok( 1 == change_counter,
146 "Missed a message: change_counter=%d\n", change_counter );
148 ok( action == change_last_param,
149 "Wrong action got %d expected %d\n", change_last_param, action );
150 change_last_param = 0;
154 * Tests the HKEY_CURRENT_USER subkey value.
155 * The value should contain string value.
158 * lpsSubKey - subkey name
159 * lpsRegName - registry entry name
160 * lpsTestValue - value to test
162 static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName, LPCSTR testValue )
164 CHAR value[MAX_PATH];
172 valueLen=sizeof(value);
173 RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey );
174 rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
176 if (rc==ERROR_SUCCESS)
178 ok( !strcmp( testValue, value ),
179 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
180 subKey1, valName, testValue, value );
185 ok(0,"Missing registry entry: subKey=%s, valName=%s\n",
188 if (subKey2 && !strict)
191 valueLen=sizeof(value);
192 RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey );
193 rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
195 if (rc==ERROR_SUCCESS)
197 ok( !strcmp( testValue, value ),
198 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
199 subKey2, valName, testValue, value );
203 ok(found,"Missing registry entry: %s in %s or %s\n",
204 valName, subKey1, (subKey2?subKey2:"<n/a>") );
207 #define test_reg_key( subKey, valName, testValue ) \
208 _test_reg_key( subKey, NULL, valName, testValue )
209 #define test_reg_key_ex( subKey1, subKey2, valName, testValue ) \
210 _test_reg_key( subKey1, subKey2, valName, testValue )
212 static void test_SPI_SETBEEP( void ) /* 2 */
219 trace("testing SPI_{GET,SET}BEEP\n");
220 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &old_b, 0 );
221 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
224 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
225 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
226 test_change_message( SPI_SETBEEP, 0 );
227 test_reg_key( SPI_SETBEEP_REGKEY,
229 curr_val ? "Yes" : "No" );
230 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
231 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
232 eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
233 rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
234 if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
236 ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
237 eq( b, curr_val, "SystemParametersInfoW", "%d" );
240 /* is a message sent for the second change? */
241 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
242 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
243 test_change_message( SPI_SETBEEP, 0 );
246 rc=SystemParametersInfoW( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
247 if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
248 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
249 ok(rc!=0,"SystemParametersInfo: rc=%d err=%ld\n",rc,GetLastError());
250 test_change_message( SPI_SETBEEP, 0 );
251 test_reg_key( SPI_SETBEEP_REGKEY,
253 curr_val ? "Yes" : "No" );
254 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
255 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
256 eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
257 rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
258 if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
260 ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
261 eq( b, curr_val, "SystemParametersInfoW", "%d" );
263 ok( MessageBeep( MB_OK ), "Return value of MessageBeep when sound is disabled\n" );
265 rc=SystemParametersInfoA( SPI_SETBEEP, old_b, 0, SPIF_UPDATEINIFILE );
266 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
269 static const char *setmouse_valuenames[3] = {
270 SPI_SETMOUSE_VALNAME1,
271 SPI_SETMOUSE_VALNAME2,
272 SPI_SETMOUSE_VALNAME3
276 * Runs check for one setting of spi_setmouse.
278 static void run_spi_setmouse_test( int curr_val[], POINT *req_change, POINT *proj_change,
283 static int aw_turn = 0;
290 if (aw_turn % 2!=0) /* call unicode version each second call */
291 rc=SystemParametersInfoW( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
292 if (aw_turn % 2==0 || (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED))
293 rc=SystemParametersInfoA( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
294 ok(rc!=0,"SystemParametersInfo: rc=%d err=%ld\n",rc,GetLastError());
295 test_change_message( SPI_SETMOUSE, 0 );
296 for (i = 0; i < 3; i++)
298 sprintf( buf, "%d", curr_val[i] );
299 test_reg_key( SPI_SETMOUSE_REGKEY, setmouse_valuenames[i], buf );
302 rc=SystemParametersInfoA( SPI_GETMOUSE, 0, mi, 0 );
303 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
304 for (i = 0; i < 3; i++)
306 ok(mi[i] == curr_val[i],
307 "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
310 rc=SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 );
311 if (rc!=0 && GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
313 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
314 for (i = 0; i < 3; i++)
316 ok(mi[i] == curr_val[i],
317 "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
321 #if 0 /* FIXME: this always fails for me - AJ */
322 for (i = 0; i < nchange; i++)
325 mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 0, 0, 0 );
326 mouse_event( MOUSEEVENTF_MOVE, req_change[i].x, req_change[i].y, 0, 0 );
328 ok( proj_change[i].x == mv.x, "Projected dx and real dx comparison. May fail under high load.\n" );
329 ok( proj_change[i].y == mv.y, "Projected dy equals real dy. May fail under high load.\n" );
334 static void test_SPI_SETMOUSE( void ) /* 4 */
339 /* win nt default values - 6, 10, 1 */
340 INT curr_val[3] = {6, 10, 1};
342 /* requested and projected mouse movements */
343 POINT req_change[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
344 POINT proj_change1[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
345 POINT proj_change2[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {44, 20}, {400, 400} };
346 POINT proj_change3[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
347 POINT proj_change4[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
348 POINT proj_change5[] = { {6, 6}, { 7, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
349 POINT proj_change6[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
350 POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
351 POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
353 int nchange = sizeof( req_change ) / sizeof( POINT );
355 trace("testing SPI_{GET,SET}MOUSE\n");
356 rc=SystemParametersInfoA( SPI_GETMOUSE, 0, old_mi, 0 );
357 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
359 run_spi_setmouse_test( curr_val, req_change, proj_change1, nchange );
361 /* acceleration change */
363 run_spi_setmouse_test( curr_val, req_change, proj_change2, nchange );
365 /* acceleration change */
367 run_spi_setmouse_test( curr_val, req_change, proj_change3, nchange );
369 /* acceleration change */
371 run_spi_setmouse_test( curr_val, req_change, proj_change4, nchange );
373 /* threshold change */
376 run_spi_setmouse_test( curr_val, req_change, proj_change5, nchange );
378 /* threshold change */
382 run_spi_setmouse_test( curr_val, req_change, proj_change6, nchange );
384 /* threshold change */
386 run_spi_setmouse_test( curr_val, req_change, proj_change7, nchange );
388 /* threshold change */
390 run_spi_setmouse_test( curr_val, req_change, proj_change8, nchange );
392 rc=SystemParametersInfoA( SPI_SETMOUSE, 0, old_mi, SPIF_UPDATEINIFILE );
393 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
397 static void test_setborder(UINT curr_val)
404 rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
405 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
406 test_change_message( SPI_SETBORDER, 1 );
407 sprintf( buf, "%d", curr_val );
408 test_reg_key( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, buf );
412 rc=SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 );
413 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
414 eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d");
416 frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME );
417 eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" );
418 eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" );
419 eq( frame, GetSystemMetrics( SM_CXSIZEFRAME ), "SM_CXSIZEFRAME", "%d" );
420 eq( frame, GetSystemMetrics( SM_CYSIZEFRAME ), "SM_CYSIZEFRAME", "%d" );
423 static void test_SPI_SETBORDER( void ) /* 6 */
428 /* These tests hang when XFree86 4.0 for Windows is running (tested on
429 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
432 if (FindWindowA( NULL, "Cygwin/XFree86" ))
435 trace("testing SPI_{GET,SET}BORDER\n");
436 rc=SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 );
437 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
444 /* This will restore sane values if the test hang previous run. */
445 if ( old_border == 7 || old_border == 20 )
448 rc=SystemParametersInfoA( SPI_SETBORDER, old_border, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
449 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
453 static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */
457 const UINT vals[]={0,20,31};
460 trace("testing SPI_{GET,SET}KEYBOARDSPEED\n");
461 rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &old_speed, 0 );
462 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
464 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
469 rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, vals[i], 0,
470 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
471 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
472 test_change_message( SPI_SETKEYBOARDSPEED, 0 );
473 sprintf( buf, "%d", vals[i] );
474 test_reg_key( SPI_SETKEYBOARDSPEED_REGKEY, SPI_SETKEYBOARDSPEED_VALNAME, buf );
476 rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &v, 0 );
477 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
478 eq( v, vals[i], "SPI_{GET,SET}KEYBOARDSPEED", "%d" );
481 rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, old_speed, 0, SPIF_UPDATEINIFILE );
482 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
485 static void test_SPI_ICONHORIZONTALSPACING( void ) /* 13 */
492 trace("testing SPI_ICONHORIZONTALSPACING\n");
493 /* default value: 75 */
494 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &old_spacing, 0 );
495 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
497 /* do not increase the value as it would upset the user's icon layout */
498 curr_val = (old_spacing > 32 ? old_spacing-1 : 32);
499 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
500 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
501 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
502 test_change_message( SPI_ICONHORIZONTALSPACING, 0 );
503 /* The registry keys depend on the Windows version and the values too
507 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
508 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
509 eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d");
510 eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
513 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
514 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
515 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
516 curr_val = 32; /*min value*/
517 test_change_message( SPI_ICONHORIZONTALSPACING, 0 );
519 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
520 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
521 eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d" );
522 eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
524 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, old_spacing, 0, SPIF_UPDATEINIFILE );
525 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
528 static void test_SPI_SETSCREENSAVETIMEOUT( void ) /* 14 */
532 const UINT vals[]={0,32767};
535 trace("testing SPI_{GET,SET}SCREENSAVETIMEOUT\n");
536 rc=SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &old_timeout, 0 );
537 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
539 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
544 rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, vals[i], 0,
545 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
546 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
547 test_change_message( SPI_SETSCREENSAVETIMEOUT, 0 );
548 sprintf( buf, "%d", vals[i] );
549 test_reg_key( SPI_SETSCREENSAVETIMEOUT_REGKEY,
550 SPI_SETSCREENSAVETIMEOUT_VALNAME, buf );
552 SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &v, 0 );
553 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
554 eq( v, vals[i], "SPI_{GET,SET}SCREENSAVETIMEOUT", "%d" );
557 rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, old_timeout, 0,
558 SPIF_UPDATEINIFILE );
559 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
562 static void test_SPI_SETSCREENSAVEACTIVE( void ) /* 17 */
566 const UINT vals[]={TRUE,FALSE};
569 trace("testing SPI_{GET,SET}SCREENSAVEACTIVE\n");
570 rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &old_b, 0 );
571 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
573 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
577 rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, vals[i], 0,
578 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
579 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
580 test_change_message( SPI_SETSCREENSAVEACTIVE, 0 );
581 test_reg_key( SPI_SETSCREENSAVEACTIVE_REGKEY,
582 SPI_SETSCREENSAVEACTIVE_VALNAME,
583 vals[i] ? "1" : "0" );
585 rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &v, 0 );
586 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
587 eq( v, vals[i], "SPI_{GET,SET}SCREENSAVEACTIVE", "%d" );
590 rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
591 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
594 static void test_SPI_SETGRIDGRANULARITY( void ) /* 19 */
599 static void test_SPI_SETKEYBOARDDELAY( void ) /* 23 */
603 const UINT vals[]={0,3};
606 trace("testing SPI_{GET,SET}KEYBOARDDELAY\n");
607 rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &old_delay, 0 );
608 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
610 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
615 rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, vals[i], 0,
616 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
617 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
618 test_change_message( SPI_SETKEYBOARDDELAY, 0 );
619 sprintf( buf, "%d", vals[i] );
620 test_reg_key( SPI_SETKEYBOARDDELAY_REGKEY,
621 SPI_SETKEYBOARDDELAY_VALNAME, buf );
623 rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &delay, 0 );
624 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
625 eq( delay, vals[i], "SPI_{GET,SET}KEYBOARDDELAY", "%d" );
628 rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, old_delay, 0, SPIF_UPDATEINIFILE );
629 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
632 static void test_SPI_ICONVERTICALSPACING( void ) /* 24 */
639 trace("testing SPI_ICONVERTICALSPACING\n");
640 /* default value: 75 */
641 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &old_spacing, 0 );
642 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
644 /* do not increase the value as it would upset the user's icon layout */
645 curr_val = old_spacing-1;
646 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
647 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
648 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
649 test_change_message( SPI_ICONVERTICALSPACING, 0 );
650 /* The registry keys depend on the Windows version and the values too
654 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
655 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
656 eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
657 eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
660 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
661 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
662 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
663 curr_val = 32; /*min value*/
664 test_change_message( SPI_ICONVERTICALSPACING, 0 );
666 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
667 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
668 eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
669 eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
671 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, old_spacing, 0,
672 SPIF_UPDATEINIFILE );
673 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
676 static void test_SPI_SETICONTITLEWRAP( void ) /* 26 */
680 const UINT vals[]={TRUE,FALSE};
683 /* These tests hang when XFree86 4.0 for Windows is running (tested on
684 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
687 if (FindWindowA( NULL, "Cygwin/XFree86" ))
690 trace("testing SPI_{GET,SET}ICONTITLEWRAP\n");
691 rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &old_b, 0 );
692 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
694 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
698 rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, vals[i], 0,
699 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
700 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
701 test_change_message( SPI_SETICONTITLEWRAP, 1 );
702 test_reg_key_ex( SPI_SETICONTITLEWRAP_REGKEY1,
703 SPI_SETICONTITLEWRAP_REGKEY2,
704 SPI_SETICONTITLEWRAP_VALNAME,
705 vals[i] ? "1" : "0" );
707 rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &v, 0 );
708 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
709 eq( v, vals[i], "SPI_{GET,SET}ICONTITLEWRAP", "%d" );
712 rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, old_b, 0, SPIF_UPDATEINIFILE );
713 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
716 static void test_SPI_SETMENUDROPALIGNMENT( void ) /* 28 */
720 const UINT vals[]={TRUE,FALSE};
723 trace("testing SPI_{GET,SET}MENUDROPALIGNMENT\n");
724 rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &old_b, 0 );
725 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
727 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
731 rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, vals[i], 0,
732 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
733 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
734 test_change_message( SPI_SETMENUDROPALIGNMENT, 0 );
735 test_reg_key_ex( SPI_SETMENUDROPALIGNMENT_REGKEY1,
736 SPI_SETMENUDROPALIGNMENT_REGKEY2,
737 SPI_SETMENUDROPALIGNMENT_VALNAME,
738 vals[i] ? "1" : "0" );
740 rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &v, 0 );
741 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
742 eq( v, vals[i], "SPI_{GET,SET}MENUDROPALIGNMENT", "%d" );
743 eq( GetSystemMetrics( SM_MENUDROPALIGNMENT ), (int)vals[i],
744 "SM_MENUDROPALIGNMENT", "%d" );
747 rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, old_b, 0,
748 SPIF_UPDATEINIFILE );
749 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
752 static void test_SPI_SETDOUBLECLKWIDTH( void ) /* 29 */
756 const UINT vals[]={0,10000};
759 trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n");
760 old_width = GetSystemMetrics( SM_CXDOUBLECLK );
762 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
766 rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, vals[i], 0,
767 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
768 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
769 test_change_message( SPI_SETDOUBLECLKWIDTH, 0 );
770 sprintf( buf, "%d", vals[i] );
771 test_reg_key_ex( SPI_SETDOUBLECLKWIDTH_REGKEY1,
772 SPI_SETDOUBLECLKWIDTH_REGKEY2,
773 SPI_SETDOUBLECLKWIDTH_VALNAME, buf );
774 eq( GetSystemMetrics( SM_CXDOUBLECLK ), (int)vals[i],
775 "SM_CXDOUBLECLK", "%d" );
778 rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, old_width, 0,
779 SPIF_UPDATEINIFILE );
780 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
783 static void test_SPI_SETDOUBLECLKHEIGHT( void ) /* 30 */
787 const UINT vals[]={0,10000};
790 trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n");
791 old_height = GetSystemMetrics( SM_CYDOUBLECLK );
793 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
797 rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, vals[i], 0,
798 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
799 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
800 test_change_message( SPI_SETDOUBLECLKHEIGHT, 0 );
801 sprintf( buf, "%d", vals[i] );
802 test_reg_key_ex( SPI_SETDOUBLECLKHEIGHT_REGKEY1,
803 SPI_SETDOUBLECLKHEIGHT_REGKEY2,
804 SPI_SETDOUBLECLKHEIGHT_VALNAME, buf );
805 eq( GetSystemMetrics( SM_CYDOUBLECLK ), (int)vals[i],
806 "SM_CYDOUBLECLK", "%d" );
809 rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, old_height, 0,
810 SPIF_UPDATEINIFILE );
811 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
814 static void test_SPI_SETDOUBLECLICKTIME( void ) /* 32 */
822 trace("testing SPI_{GET,SET}DOUBLECLICKTIME\n");
823 old_time = GetDoubleClickTime();
826 rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
827 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
828 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
829 test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
830 sprintf( buf, "%d", curr_val );
831 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
832 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
833 curr_val = 500; /* used value for 0 */
834 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
837 rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
838 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
839 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
840 test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
841 sprintf( buf, "%d", curr_val );
842 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
843 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
844 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
846 saved_val = curr_val;
849 SetDoubleClickTime( curr_val );
850 sprintf( buf, "%d", saved_val );
851 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
852 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
853 curr_val = 500; /* used value for 0 */
854 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
857 SetDoubleClickTime( curr_val );
858 sprintf( buf, "%d", saved_val );
859 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
860 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
861 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
863 rc=SystemParametersInfoA(SPI_SETDOUBLECLICKTIME, old_time, 0, SPIF_UPDATEINIFILE);
864 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
867 static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
871 const UINT vals[]={TRUE,FALSE};
874 trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
875 old_b = GetSystemMetrics( SM_SWAPBUTTON );
877 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
879 rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0,
880 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
881 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
882 test_change_message( SPI_SETMOUSEBUTTONSWAP, 0 );
883 test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY,
884 SPI_SETMOUSEBUTTONSWAP_VALNAME,
885 vals[i] ? "1" : "0" );
886 eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i],
887 "SM_SWAPBUTTON", "%d" );
890 rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0,
891 SPIF_UPDATEINIFILE );
892 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
895 static void test_SPI_SETFASTTASKSWITCH( void ) /* 36 */
900 trace("testing SPI_GETFASTTASKSWITCH\n");
901 rc=SystemParametersInfoA( SPI_GETFASTTASKSWITCH, 0, &v, 0 );
902 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
903 /* there is not a single Windows platform on which SPI_GETFASTTASKSWITCH
904 * works. That sure simplifies testing!
908 static void test_SPI_SETDRAGFULLWINDOWS( void ) /* 37 */
912 const UINT vals[]={TRUE,FALSE};
915 trace("testing SPI_{GET,SET}DRAGFULLWINDOWS\n");
916 rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &old_b, 0 );
917 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_CALL_NOT_IMPLEMENTED))
919 /* SPI_{GET,SET}DRAGFULLWINDOWS is not implemented on Win95 */
920 trace("SPI_{GET,SET}DRAGFULLWINDOWS not supported on this platform\n");
923 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
925 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
929 rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, vals[i], 0,
930 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
931 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
932 test_change_message( SPI_SETDRAGFULLWINDOWS, 0 );
933 test_reg_key( SPI_SETDRAGFULLWINDOWS_REGKEY,
934 SPI_SETDRAGFULLWINDOWS_VALNAME,
935 vals[i] ? "1" : "0" );
937 rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &v, 0 );
938 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
939 eq( v, vals[i], "SPI_{GET,SET}DRAGFULLWINDOWS", "%d" );
942 rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, old_b, 0, SPIF_UPDATEINIFILE );
943 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
946 static void test_SPI_SETWORKAREA( void ) /* 47 */
953 trace("testing SPI_{GET,SET}WORKAREA\n");
954 rc=SystemParametersInfoA(SPI_GETWORKAREA, 0, &old_area, 0);
955 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
957 /* Modify the work area only minimally as this causes the icons that
958 * fall outside it to be moved around thus requiring the user to
959 * reposition them manually one by one.
960 * Changing the work area by just one pixel should make this occurence
961 * reasonably unlikely.
963 curr_val.left = old_area.left;
964 curr_val.top = old_area.top;
965 curr_val.right = old_area.right-1;
966 curr_val.bottom = old_area.bottom-1;
967 rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &curr_val,
968 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
969 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
970 test_change_message( SPI_SETWORKAREA, 0 );
971 rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
972 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
973 eq( area.left, curr_val.left, "left", "%ld" );
974 eq( area.top, curr_val.top, "top", "%ld" );
975 eq( area.right, curr_val.right, "right", "%ld" );
976 eq( area.bottom, curr_val.bottom, "bottom", "%ld" );
978 rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &old_area,
979 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
980 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
981 test_change_message( SPI_SETWORKAREA, 0 );
982 rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
983 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
984 eq( area.left, old_area.left, "left", "%ld" );
985 eq( area.top, old_area.top, "top", "%ld" );
986 eq( area.right, old_area.right, "right", "%ld" );
987 eq( area.bottom, old_area.bottom, "bottom", "%ld" );
990 static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */
994 const UINT vals[]={TRUE,FALSE};
997 trace("testing SPI_{GET,SET}SHOWSOUNDS\n");
999 rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &old_b, 0 );
1000 if (rc==0 && GetLastError()==0)
1002 /* SPI_{GET,SET}SHOWSOUNDS is completely broken on Win9x */
1003 trace("SPI_{GET,SET}SHOWSOUNDS not supported on this platform\n");
1006 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1008 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1012 rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, vals[i], 0,
1013 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1014 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1015 test_change_message( SPI_SETSHOWSOUNDS, 0 );
1016 test_reg_key( SPI_SETSHOWSOUNDS_REGKEY,
1017 SPI_SETSHOWSOUNDS_VALNAME,
1018 vals[i] ? "1" : "0" );
1020 rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &v, 0 );
1021 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1022 eq( v, vals[i], "SPI_GETSHOWSOUNDS", "%d" );
1023 eq( GetSystemMetrics( SM_SHOWSOUNDS ), (int)vals[i],
1024 "SM_SHOWSOUNDS", "%d" );
1027 rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, old_b, 0, SPIF_UPDATEINIFILE );
1028 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1031 static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
1033 /* TODO!!! - don't have version of Windows which has this */
1036 static void test_SPI_SETSCREENREADER( void ) /* 71 */
1038 /* TODO!!! - don't have version of Windows which has this */
1041 static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */
1045 const UINT vals[]={0,32767};
1048 trace("testing SPI_{GET,SET}MOUSEHOVERWIDTH\n");
1049 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH, 0, &old_width, 0 );
1050 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1052 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1053 * what MSDN states (Verified on Win98SE)
1055 trace("SPI_{GET,SET}MOUSEHOVERWIDTH not supported on this platform\n");
1058 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1060 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1065 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH, vals[i], 0,
1066 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1067 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1068 test_change_message( SPI_SETMOUSEHOVERWIDTH, 0 );
1069 sprintf( buf, "%d", vals[i] );
1070 test_reg_key( SPI_SETMOUSEHOVERWIDTH_REGKEY,
1071 SPI_SETMOUSEHOVERWIDTH_VALNAME, buf );
1073 SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH, 0, &v, 0 );
1074 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1075 eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERWIDTH", "%d" );
1078 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH, old_width, 0,
1079 SPIF_UPDATEINIFILE );
1080 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1083 static void test_SPI_SETMOUSEHOVERHEIGHT( void ) /* 101 */
1087 const UINT vals[]={0,32767};
1090 trace("testing SPI_{GET,SET}MOUSEHOVERHEIGHT\n");
1091 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT, 0, &old_height, 0 );
1092 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1094 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1095 * what MSDN states (Verified on Win98SE)
1097 trace("SPI_{GET,SET}MOUSEHOVERHEIGHT not supported on this platform\n");
1100 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1102 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1107 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT, vals[i], 0,
1108 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1109 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1110 test_change_message( SPI_SETMOUSEHOVERHEIGHT, 0 );
1111 sprintf( buf, "%d", vals[i] );
1112 test_reg_key( SPI_SETMOUSEHOVERHEIGHT_REGKEY,
1113 SPI_SETMOUSEHOVERHEIGHT_VALNAME, buf );
1115 SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT, 0, &v, 0 );
1116 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1117 eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERHEIGHT", "%d" );
1120 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT, old_height, 0,
1121 SPIF_UPDATEINIFILE );
1122 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1125 static void test_SPI_SETMOUSEHOVERTIME( void ) /* 103 */
1129 const UINT vals[]={0,32767};
1132 trace("testing SPI_{GET,SET}MOUSEHOVERTIME\n");
1133 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERTIME, 0, &old_time, 0 );
1134 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1136 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1137 * what MSDN states (Verified on Win98SE)
1139 trace("SPI_{GET,SET}MOUSEHOVERTIME not supported on this platform\n");
1142 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1144 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1149 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME, vals[i], 0,
1150 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1151 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1152 test_change_message( SPI_SETMOUSEHOVERTIME, 0 );
1153 sprintf( buf, "%d", vals[i] );
1154 test_reg_key( SPI_SETMOUSEHOVERTIME_REGKEY,
1155 SPI_SETMOUSEHOVERTIME_VALNAME, buf );
1157 SystemParametersInfoA( SPI_GETMOUSEHOVERTIME, 0, &v, 0 );
1158 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1159 eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERTIME", "%d" );
1162 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME, old_time, 0,
1163 SPIF_UPDATEINIFILE );
1164 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1167 static void test_SPI_SETWHEELSCROLLLINES( void ) /* 105 */
1171 const UINT vals[]={0,32767};
1174 trace("testing SPI_{GET,SET}WHEELSCROLLLINES\n");
1175 rc=SystemParametersInfoA( SPI_GETWHEELSCROLLLINES, 0, &old_lines, 0 );
1176 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1178 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1183 rc=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES, vals[i], 0,
1184 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1185 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1186 test_change_message( SPI_SETWHEELSCROLLLINES, 0 );
1187 sprintf( buf, "%d", vals[i] );
1188 test_reg_key( SPI_SETMOUSESCROLLLINES_REGKEY,
1189 SPI_SETMOUSESCROLLLINES_VALNAME, buf );
1191 SystemParametersInfoA( SPI_GETWHEELSCROLLLINES, 0, &v, 0 );
1192 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1193 eq( v, vals[i], "SPI_{GET,SET}MOUSESCROLLLINES", "%d" );
1196 rc=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES, old_lines, 0,
1197 SPIF_UPDATEINIFILE );
1198 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1201 static void test_SPI_SETMENUSHOWDELAY( void ) /* 107 */
1205 const UINT vals[]={0,32767};
1208 trace("testing SPI_{GET,SET}MENUSHOWDELAY\n");
1209 rc=SystemParametersInfoA( SPI_GETMENUSHOWDELAY, 0, &old_delay, 0 );
1210 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1212 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1217 rc=SystemParametersInfoA( SPI_SETMENUSHOWDELAY, vals[i], 0,
1218 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1219 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1220 test_change_message( SPI_SETMENUSHOWDELAY, 0 );
1221 sprintf( buf, "%d", vals[i] );
1222 test_reg_key( SPI_SETMENUSHOWDELAY_REGKEY,
1223 SPI_SETMENUSHOWDELAY_VALNAME, buf );
1225 SystemParametersInfoA( SPI_GETMENUSHOWDELAY, 0, &v, 0 );
1226 ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1227 eq( v, vals[i], "SPI_{GET,SET}MENUSHOWDELAY", "%d" );
1230 rc=SystemParametersInfoA( SPI_SETMENUSHOWDELAY, old_delay, 0,
1231 SPIF_UPDATEINIFILE );
1232 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1235 static void test_SPI_SETWALLPAPER( void ) /* 115 */
1241 trace("testing SPI_{GET,SET}DESKWALLPAPER\n");
1243 rc=SystemParametersInfoA(SPI_GETDESKWALLPAPER, 260, oldval, 0);
1244 if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1246 /* SPI_{GET,SET}DESKWALLPAPER is completely broken on Win9x and
1247 * unimplemented on NT4
1249 trace("SPI_{GET,SET}DESKWALLPAPER not supported on this platform\n");
1252 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1255 rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, newval, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
1256 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1257 test_change_message(SPI_SETDESKWALLPAPER, 0);
1259 rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, oldval, SPIF_UPDATEINIFILE);
1260 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1262 test_reg_key(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, oldval);
1266 * Registry entries for the system parameters.
1267 * Names are created by 'SET' flags names.
1268 * We assume that corresponding 'GET' entries use the same registry keys.
1270 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
1272 test_SPI_SETBEEP(); /* 1 */
1273 test_SPI_SETMOUSE(); /* 4 */
1274 /* Messes up systems settings on Win9x */
1275 /*test_SPI_SETBORDER();*/ /* 6 */
1276 test_SPI_SETKEYBOARDSPEED(); /* 10 */
1277 test_SPI_ICONHORIZONTALSPACING(); /* 13 */
1278 test_SPI_SETSCREENSAVETIMEOUT(); /* 14 */
1279 test_SPI_SETSCREENSAVEACTIVE(); /* 17 */
1280 test_SPI_SETGRIDGRANULARITY(); /* 19 */
1281 test_SPI_SETKEYBOARDDELAY(); /* 23 */
1282 test_SPI_ICONVERTICALSPACING(); /* 24 */
1283 test_SPI_SETICONTITLEWRAP(); /* 26 */
1284 test_SPI_SETMENUDROPALIGNMENT(); /* 28 */
1285 test_SPI_SETDOUBLECLKWIDTH(); /* 29 */
1286 test_SPI_SETDOUBLECLKHEIGHT(); /* 30 */
1287 test_SPI_SETDOUBLECLICKTIME(); /* 32 */
1288 test_SPI_SETMOUSEBUTTONSWAP(); /* 33 */
1289 test_SPI_SETFASTTASKSWITCH(); /* 36 */
1290 test_SPI_SETDRAGFULLWINDOWS(); /* 37 */
1291 test_SPI_SETWORKAREA(); /* 47 */
1292 test_SPI_SETSHOWSOUNDS(); /* 57 */
1293 test_SPI_SETKEYBOARDPREF(); /* 69 */
1294 test_SPI_SETSCREENREADER(); /* 71 */
1295 test_SPI_SETMOUSEHOVERWIDTH(); /* 99 */
1296 test_SPI_SETMOUSEHOVERHEIGHT(); /* 101 */
1297 test_SPI_SETMOUSEHOVERTIME(); /* 103 */
1298 test_SPI_SETWHEELSCROLLLINES(); /* 105 */
1299 test_SPI_SETMENUSHOWDELAY(); /* 107 */
1300 test_SPI_SETWALLPAPER(); /* 115 */
1301 SendMessageA( ghTestWnd, WM_DESTROY, 0, 0 );
1305 START_TEST(sysparams)
1313 HANDLE hInstance = GetModuleHandleA( NULL );
1315 argc = winetest_get_mainargs(&argv);
1316 strict=(argc >= 3 && strcmp(argv[2],"strict")==0);
1317 trace("strict=%d\n",strict);
1320 change_last_param = 0;
1322 wc.lpszClassName = "SysParamsTestClass";
1323 wc.lpfnWndProc = SysParamsTestWndProc;
1324 wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
1325 wc.hInstance = hInstance;
1326 wc.hIcon = LoadIconA( 0, (LPSTR)IDI_APPLICATION );
1327 wc.hCursor = LoadCursorA( 0, (LPSTR)IDC_ARROW );
1328 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1 );
1329 wc.lpszMenuName = 0;
1332 RegisterClassA( &wc );
1334 ghTestWnd = CreateWindowA( "SysParamsTestClass", "Test System Parameters Application",
1335 WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, hInstance, NULL );
1337 hThread = CreateThread( NULL, 0, SysParamsThreadFunc, 0, 0, &dwThreadId );
1339 CloseHandle( hThread );
1341 while( GetMessageA( &msg, 0, 0, 0 )) {
1342 TranslateMessage( &msg );
1343 DispatchMessageA( &msg );