Fix image list mask and blending.
[wine] / dlls / user / tests / sysparams.c
1 /* Unit test suite for functions SystemParametersInfo and GetSystemMetrics.
2  *
3  * Copyright 2002 Andriy Palamarchuk
4  *
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.
9  *
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.
14  *
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
18  */
19
20 #include <assert.h>
21 #include <stdlib.h>
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #define _WIN32_WINNT 0x0500 /* For SPI_GETMOUSEHOVERWIDTH and more */
26
27 #include "wine/test.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "winuser.h"
32
33 #ifndef SPI_GETDESKWALLPAPER
34 # define SPI_GETDESKWALLPAPER 0x0073
35 #endif
36
37 static int strict;
38
39 #define eq(received, expected, label, type) \
40         ok((received) == (expected), "%s: got " type " instead of " type "\n", (label),(received),(expected))
41
42
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     "???"
100
101 /* volatile registry branch under CURRENT_USER_REGKEY for temporary values storage */
102 #define WINE_CURRENT_USER_REGKEY     "Wine"
103
104 static HWND ghTestWnd;
105
106 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam );
107 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
108                                               LPARAM lParam );
109 static int change_counter;
110 static int change_last_param;
111
112 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
113                                               LPARAM lParam )
114 {
115     switch (msg) {
116
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);
121         }
122         change_counter++;
123         change_last_param = wParam;
124         break;
125
126     case WM_DESTROY:
127         PostQuitMessage( 0 );
128         break;
129
130     default:
131         return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
132     }
133
134     return 0;
135 }
136
137 /*
138 Performs testing for system parameters messages
139 params:
140  - system parameter id
141  - supposed value of the registry key
142 */
143 static void test_change_message( int action, int optional )
144 {
145     if (change_counter==0 && optional==1)
146         return;
147     ok( 1 == change_counter,
148         "Missed a message: change_counter=%d\n", change_counter );
149     change_counter = 0;
150     ok( action == change_last_param,
151         "Wrong action got %d expected %d\n", change_last_param, action );
152     change_last_param = 0;
153 }
154
155 /*
156  * Tests the HKEY_CURRENT_USER subkey value.
157  * The value should contain string value.
158  *
159  * Params:
160  * lpsSubKey - subkey name
161  * lpsRegName - registry entry name
162  * lpsTestValue - value to test
163  */
164 static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName, LPCSTR testValue )
165 {
166     CHAR  value[MAX_PATH];
167     DWORD valueLen;
168     DWORD type;
169     HKEY hKey;
170     LONG rc;
171     int found=0;
172
173     *value='\0';
174     valueLen=sizeof(value);
175     RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey );
176     rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
177     RegCloseKey( hKey );
178     if (rc==ERROR_SUCCESS)
179     {
180         ok( !strcmp( testValue, value ),
181             "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
182             subKey1, valName, testValue, value );
183         found++;
184     }
185     else if (strict)
186     {
187         ok(0,"Missing registry entry: subKey=%s, valName=%s\n",
188            subKey1, valName);
189     }
190     if (subKey2 && !strict)
191     {
192         *value='\0';
193         valueLen=sizeof(value);
194         RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey );
195         rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
196         RegCloseKey( hKey );
197         if (rc==ERROR_SUCCESS)
198         {
199             ok( !strcmp( testValue, value ),
200                 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
201                 subKey2, valName, testValue, value );
202             found++;
203         }
204     }
205     ok(found,"Missing registry entry: %s in %s or %s\n",
206        valName, subKey1, (subKey2?subKey2:"<n/a>") );
207 }
208
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 )
213
214 static void test_SPI_SETBEEP( void )                   /*      2 */
215 {
216     BOOL rc;
217     BOOL old_b;
218     BOOL b;
219     BOOL curr_val;
220
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());
224
225     curr_val = TRUE;
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,
230                   SPI_SETBEEP_VALNAME,
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)
237     {
238         ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
239         eq( b, curr_val, "SystemParametersInfoW", "%d" );
240     }
241
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 );
246
247     curr_val = FALSE;
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,
254                   SPI_SETBEEP_VALNAME,
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)
261     {
262         ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
263         eq( b, curr_val, "SystemParametersInfoW", "%d" );
264     }
265     ok( MessageBeep( MB_OK ), "Return value of MessageBeep when sound is disabled\n" );
266
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());
269 }
270
271 static const char *setmouse_valuenames[3] = {
272     SPI_SETMOUSE_VALNAME1,
273     SPI_SETMOUSE_VALNAME2,
274     SPI_SETMOUSE_VALNAME3
275 };
276
277 /*
278  * Runs check for one setting of spi_setmouse.
279  */
280 static void run_spi_setmouse_test( int curr_val[], POINT *req_change, POINT *proj_change,
281                                    int nchange )
282 {
283     BOOL rc;
284     INT mi[3];
285     static int aw_turn = 0;
286
287     char buf[20];
288     int i;
289
290     aw_turn++;
291     rc=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++)
299     {
300         sprintf( buf, "%d", curr_val[i] );
301         test_reg_key( SPI_SETMOUSE_REGKEY, setmouse_valuenames[i], buf );
302     }
303
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++)
307     {
308         ok(mi[i] == curr_val[i],
309            "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
310     }
311
312     rc=SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 );
313     if (rc!=0 && GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
314     {
315         ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
316         for (i = 0; i < 3; i++)
317         {
318             ok(mi[i] == curr_val[i],
319                "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
320         }
321     }
322
323 #if 0  /* FIXME: this always fails for me  - AJ */
324     for (i = 0; i < nchange; i++)
325     {
326         POINT mv;
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 );
329         GetCursorPos( &mv );
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" );
332     }
333 #endif
334 }
335
336 static void test_SPI_SETMOUSE( void )                  /*      4 */
337 {
338     BOOL rc;
339     INT old_mi[3];
340
341     /* win nt default values - 6, 10, 1 */
342     INT curr_val[3] = {6, 10, 1};
343
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} };
354
355     int nchange = sizeof( req_change ) / sizeof( POINT );
356
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());
360
361     run_spi_setmouse_test( curr_val, req_change, proj_change1, nchange );
362
363     /* acceleration change */
364     curr_val[2] = 2;
365     run_spi_setmouse_test( curr_val, req_change, proj_change2, nchange );
366
367     /* acceleration change */
368     curr_val[2] = 3;
369     run_spi_setmouse_test( curr_val, req_change, proj_change3, nchange );
370
371     /* acceleration change */
372     curr_val[2] = 0;
373     run_spi_setmouse_test( curr_val, req_change, proj_change4, nchange );
374
375     /* threshold change */
376     curr_val[2] = 1;
377     curr_val[0] = 7;
378     run_spi_setmouse_test( curr_val, req_change, proj_change5, nchange );
379
380     /* threshold change */
381     curr_val[2] = 2;
382     curr_val[0] = 6;
383     curr_val[1] = 6;
384     run_spi_setmouse_test( curr_val, req_change, proj_change6, nchange );
385
386     /* threshold change */
387     curr_val[1] = 7;
388     run_spi_setmouse_test( curr_val, req_change, proj_change7, nchange );
389
390     /* threshold change */
391     curr_val[1] = 5;
392     run_spi_setmouse_test( curr_val, req_change, proj_change8, nchange );
393
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());
396 }
397
398 #if 0
399 static void test_setborder(UINT curr_val)
400 {
401     BOOL rc;
402     UINT border;
403     INT frame;
404     char buf[10];
405
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 );
411
412     if (curr_val == 0)
413         curr_val = 1;
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");
417
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" );
423 }
424
425 static void test_SPI_SETBORDER( void )                 /*      6 */
426 {
427     BOOL rc;
428     UINT old_border;
429
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
432      * running.
433      */
434     if (FindWindowA( NULL, "Cygwin/XFree86" ))
435         return;
436
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());
440
441     test_setborder(1);
442     test_setborder(0);
443     test_setborder(7);
444     test_setborder(20);
445
446     /* This will restore sane values if the test hang previous run. */
447     if ( old_border == 7 || old_border == 20 )
448         old_border = -15;
449
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());
452 }
453 #endif
454
455 static void test_SPI_SETKEYBOARDSPEED( void )          /*     10 */
456 {
457     BOOL rc;
458     UINT old_speed;
459     const UINT vals[]={0,20,31};
460     unsigned int i;
461
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());
465
466     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
467     {
468         UINT v;
469         char buf[10];
470
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 );
477
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" );
481     }
482
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());
485 }
486
487 static void test_SPI_ICONHORIZONTALSPACING( void )     /*     13 */
488 {
489     BOOL rc;
490     INT old_spacing;
491     INT spacing;
492     INT curr_val;
493
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());
498
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
506      * => don't test them
507      */
508
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" );
513
514     curr_val = 10;
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 );
520
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" );
525
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());
528 }
529
530 static void test_SPI_SETSCREENSAVETIMEOUT( void )      /*     14 */
531 {
532     BOOL rc;
533     UINT old_timeout;
534     const UINT vals[]={0,32767};
535     unsigned int i;
536
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());
540
541     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
542     {
543         UINT v;
544         char buf[10];
545
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 );
553
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" );
557     }
558
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());
562 }
563
564 static void test_SPI_SETSCREENSAVEACTIVE( void )       /*     17 */
565 {
566     BOOL rc;
567     BOOL old_b;
568     const UINT vals[]={TRUE,FALSE};
569     unsigned int i;
570
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());
574
575     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
576     {
577         UINT v;
578
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" );
586
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" );
590     }
591
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());
594 }
595
596 static void test_SPI_SETGRIDGRANULARITY( void )        /*     19 */
597 {
598     /* ??? */;
599 }
600
601 static void test_SPI_SETKEYBOARDDELAY( void )          /*     23 */
602 {
603     BOOL rc;
604     UINT old_delay;
605     const UINT vals[]={0,3};
606     unsigned int i;
607
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());
611
612     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
613     {
614         UINT delay;
615         char buf[10];
616
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 );
624
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" );
628     }
629
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());
632 }
633
634 static void test_SPI_ICONVERTICALSPACING( void )       /*     24 */
635 {
636     BOOL rc;
637     INT old_spacing;
638     INT spacing;
639     INT curr_val;
640
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());
645
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
653      * => don't test them
654      */
655
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" );
660
661     curr_val = 10;
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 );
667
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" );
672
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());
676 }
677
678 static void test_SPI_SETICONTITLEWRAP( void )          /*     26 */
679 {
680     BOOL rc;
681     BOOL old_b;
682     const UINT vals[]={TRUE,FALSE};
683     unsigned int i;
684
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
687      * running.
688      */
689     if (FindWindowA( NULL, "Cygwin/XFree86" ))
690         return;
691
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());
695
696     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
697     {
698         UINT v;
699
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" );
708
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" );
712     }
713
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());
716 }
717
718 static void test_SPI_SETMENUDROPALIGNMENT( void )      /*     28 */
719 {
720     BOOL rc;
721     BOOL old_b;
722     const UINT vals[]={TRUE,FALSE};
723     unsigned int i;
724
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());
728
729     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
730     {
731         UINT v;
732
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" );
741
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" );
747     }
748
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());
752 }
753
754 static void test_SPI_SETDOUBLECLKWIDTH( void )         /*     29 */
755 {
756     BOOL rc;
757     INT old_width;
758     const UINT vals[]={0,10000};
759     unsigned int i;
760
761     trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n");
762     old_width = GetSystemMetrics( SM_CXDOUBLECLK );
763
764     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
765     {
766         char buf[10];
767
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" );
778     }
779
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());
783 }
784
785 static void test_SPI_SETDOUBLECLKHEIGHT( void )        /*     30 */
786 {
787     BOOL rc;
788     INT old_height;
789     const UINT vals[]={0,10000};
790     unsigned int i;
791
792     trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n");
793     old_height = GetSystemMetrics( SM_CYDOUBLECLK );
794
795     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
796     {
797         char buf[10];
798
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" );
809     }
810
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());
814 }
815
816 static void test_SPI_SETDOUBLECLICKTIME( void )        /*     32 */
817 {
818     BOOL rc;
819     UINT curr_val;
820     UINT saved_val;
821     UINT old_time;
822     char buf[10];
823
824     trace("testing SPI_{GET,SET}DOUBLECLICKTIME\n");
825     old_time = GetDoubleClickTime();
826
827     curr_val = 0;
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" );
837
838     curr_val = 1000;
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" );
847
848     saved_val = curr_val;
849
850     curr_val = 0;
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" );
857
858     curr_val = 1000;
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" );
864
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());
867 }
868
869 static void test_SPI_SETMOUSEBUTTONSWAP( void )        /*     33 */
870 {
871     BOOL rc;
872     BOOL old_b;
873     const UINT vals[]={TRUE,FALSE};
874     unsigned int i;
875
876     trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
877     old_b = GetSystemMetrics( SM_SWAPBUTTON );
878
879     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
880     {
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" );
890     }
891
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());
895 }
896
897 static void test_SPI_SETFASTTASKSWITCH( void )         /*     36 */
898 {
899     BOOL rc;
900     BOOL v;
901
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!
907      */
908 }
909
910 static void test_SPI_SETDRAGFULLWINDOWS( void )        /*     37 */
911 {
912     BOOL rc;
913     BOOL old_b;
914     const UINT vals[]={TRUE,FALSE};
915     unsigned int i;
916
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))
920     {
921         /* SPI_{GET,SET}DRAGFULLWINDOWS is not implemented on Win95 */
922         trace("SPI_{GET,SET}DRAGFULLWINDOWS not supported on this platform\n");
923         return;
924     }
925     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
926
927     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
928     {
929         UINT v;
930
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" );
938
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" );
942     }
943
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());
946 }
947
948 static void test_SPI_SETWORKAREA( void )               /*     47 */
949 {
950     BOOL rc;
951     RECT old_area;
952     RECT area;
953     RECT curr_val;
954
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());
958
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.
964      */
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" );
979
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" );
990 }
991
992 static void test_SPI_SETSHOWSOUNDS( void )             /*     57 */
993 {
994     BOOL rc;
995     BOOL old_b;
996     const UINT vals[]={TRUE,FALSE};
997     unsigned int i;
998
999     trace("testing SPI_{GET,SET}SHOWSOUNDS\n");
1000     SetLastError(0);
1001     rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &old_b, 0 );
1002     if (rc==0 && GetLastError()==0)
1003     {
1004         /* SPI_{GET,SET}SHOWSOUNDS is completely broken on Win9x */
1005         trace("SPI_{GET,SET}SHOWSOUNDS not supported on this platform\n");
1006         return;
1007     }
1008     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1009
1010     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1011     {
1012         UINT v;
1013
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" );
1021
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" );
1027     }
1028
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());
1031 }
1032
1033 static void test_SPI_SETKEYBOARDPREF( void )           /*     69 */
1034 {
1035     /* TODO!!! - don't have version of Windows which has this */
1036 }
1037
1038 static void test_SPI_SETSCREENREADER( void )           /*     71 */
1039 {
1040     /* TODO!!! - don't have version of Windows which has this */
1041 }
1042
1043 static void test_SPI_SETMOUSEHOVERWIDTH( void )      /*     99 */
1044 {
1045     BOOL rc;
1046     UINT old_width;
1047     const UINT vals[]={0,32767};
1048     unsigned int i;
1049
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))
1053     {
1054         /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1055          * what MSDN states (Verified on Win98SE)
1056          */
1057         trace("SPI_{GET,SET}MOUSEHOVERWIDTH not supported on this platform\n");
1058         return;
1059     }
1060     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1061     
1062     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1063     {
1064         UINT v;
1065         char buf[10];
1066
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 );
1074
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" );
1078     }
1079
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());
1083 }
1084
1085 static void test_SPI_SETMOUSEHOVERHEIGHT( void )      /*     101 */
1086 {
1087     BOOL rc;
1088     UINT old_height;
1089     const UINT vals[]={0,32767};
1090     unsigned int i;
1091
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))
1095     {
1096         /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1097          * what MSDN states (Verified on Win98SE)
1098          */
1099         trace("SPI_{GET,SET}MOUSEHOVERHEIGHT not supported on this platform\n");
1100         return;
1101     }
1102     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1103     
1104     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1105     {
1106         UINT v;
1107         char buf[10];
1108
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 );
1116
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" );
1120     }
1121
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());
1125 }
1126
1127 static void test_SPI_SETMOUSEHOVERTIME( void )      /*     103 */
1128 {
1129     BOOL rc;
1130     UINT old_time;
1131     const UINT vals[]={0,32767};
1132     unsigned int i;
1133
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))
1137     {
1138         /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1139          * what MSDN states (Verified on Win98SE)
1140          */
1141         trace("SPI_{GET,SET}MOUSEHOVERTIME not supported on this platform\n");
1142         return;
1143     }
1144     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1145     
1146     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1147     {
1148         UINT v;
1149         char buf[10];
1150
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 );
1158
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" );
1162     }
1163
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());
1167 }
1168
1169 static void test_SPI_SETWHEELSCROLLLINES( void )      /*     105 */
1170 {
1171     BOOL rc;
1172     UINT old_lines;
1173     const UINT vals[]={0,32767};
1174     unsigned int i;
1175
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());
1179
1180     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1181     {
1182         UINT v;
1183         char buf[10];
1184
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 );
1192
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" );
1196     }
1197
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());
1201 }
1202
1203 static void test_SPI_SETMENUSHOWDELAY( void )      /*     107 */
1204 {
1205     BOOL rc;
1206     UINT old_delay;
1207     const UINT vals[]={0,32767};
1208     unsigned int i;
1209
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());
1213
1214     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1215     {
1216         UINT v;
1217         char buf[10];
1218
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 );
1226
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" );
1230     }
1231
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());
1235 }
1236
1237 static void test_SPI_SETWALLPAPER( void )              /*   115 */
1238 {
1239     BOOL rc;
1240     char oldval[260];
1241     char newval[260];
1242
1243     trace("testing SPI_{GET,SET}DESKWALLPAPER\n");
1244     SetLastError(0);
1245     rc=SystemParametersInfoA(SPI_GETDESKWALLPAPER, 260, oldval, 0);
1246     if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1247     {
1248         /* SPI_{GET,SET}DESKWALLPAPER is completely broken on Win9x and
1249          * unimplemented on NT4
1250          */
1251         trace("SPI_{GET,SET}DESKWALLPAPER not supported on this platform\n");
1252         return;
1253     }
1254     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1255
1256     strcpy(newval, "");
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);
1260
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());
1263
1264     test_reg_key(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, oldval);
1265 }
1266
1267 /*
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.
1271  */
1272 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
1273 {
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 );
1304     return 0;
1305 }
1306
1307 START_TEST(sysparams)
1308 {
1309     int argc;
1310     char** argv;
1311     WNDCLASSA wc;
1312     MSG msg;
1313     HANDLE hThread;
1314     DWORD dwThreadId;
1315     HANDLE hInstance = GetModuleHandleA( NULL );
1316
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;
1320
1321     argc = winetest_get_mainargs(&argv);
1322     strict=(argc >= 3 && strcmp(argv[2],"strict")==0);
1323     trace("strict=%d\n",strict);
1324
1325     change_counter = 0;
1326     change_last_param = 0;
1327
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;
1336     wc.cbClsExtra = 0;
1337     wc.cbWndExtra = 0;
1338     RegisterClassA( &wc );
1339
1340     ghTestWnd = CreateWindowA( "SysParamsTestClass", "Test System Parameters Application",
1341                                WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, hInstance, NULL );
1342
1343     hThread = CreateThread( NULL, 0, SysParamsThreadFunc, 0, 0, &dwThreadId );
1344     assert( hThread );
1345     CloseHandle( hThread );
1346
1347     while( GetMessageA( &msg, 0, 0, 0 )) {
1348         TranslateMessage( &msg );
1349         DispatchMessageA( &msg );
1350     }
1351 }