2 * COPYRIGHT: GPL, see COPYING in the top level directory
3 * PROJECT: ReactOS win32 kernel mode subsystem server
4 * PURPOSE: System parameters functions
5 * FILE: win32ss/user/ntuser/sysparams.c
6 * PROGRAMER: Timo Kreuzer (timo.kreuzer@reactos.org)
10 // - Check all values that are in Winsta in ROS.
11 // - Does setting invalid fonts work?
12 // - Save appropriate text metrics.
15 DBG_DEFAULT_CHANNEL(UserSysparams
);
18 BOOL gbSpiInitialized
= FALSE
;
19 BOOL g_PaintDesktopVersion
= FALSE
;
21 // HACK! We initialize SPI before we have a proper surface to get this from.
23 //(pPrimarySurface->GDIInfo.ulLogPixelsY)
24 #define REG2METRIC(reg) (reg > 0 ? reg : ((-(reg) * dpi + 720) / 1440))
25 #define METRIC2REG(met) (-((((met) * 1440)- 0) / dpi))
27 #define REQ_INTERACTIVE_WINSTA(err) \
29 if (GetW32ProcessInfo()->prpwinsta != InputWindowStation) \
31 if (GetW32ProcessInfo()->prpwinsta == NULL) \
33 ERR("NtUserSystemParametersInfo called without active window station, and it requires an interactive one\n"); \
37 ERR("NtUserSystemParametersInfo requires interactive window station (current is '%wZ')\n", \
38 &(OBJECT_HEADER_TO_NAME_INFO(OBJECT_TO_OBJECT_HEADER(GetW32ProcessInfo()->prpwinsta))->Name)); \
40 EngSetLastError(err); \
45 static const WCHAR
* KEY_MOUSE
= L
"Control Panel\\Mouse";
46 static const WCHAR
* VAL_MOUSE1
= L
"MouseThreshold1";
47 static const WCHAR
* VAL_MOUSE2
= L
"MouseThreshold2";
48 static const WCHAR
* VAL_MOUSE3
= L
"MouseSpeed";
49 static const WCHAR
* VAL_MOUSETRAILS
= L
"MouseTrails";
50 static const WCHAR
* VAL_DBLCLKWIDTH
= L
"DoubleClickWidth";
51 static const WCHAR
* VAL_DBLCLKHEIGHT
= L
"DoubleClickHeight";
52 static const WCHAR
* VAL_DBLCLKTIME
= L
"DoubleClickSpeed";
53 static const WCHAR
* VAL_SNAPDEFBTN
= L
"SnapToDefaultButton";
54 static const WCHAR
* VAL_SWAP
= L
"SwapMouseButtons";
55 static const WCHAR
* VAL_HOVERTIME
= L
"MouseHoverTime";
56 static const WCHAR
* VAL_HOVERWIDTH
= L
"MouseHoverWidth";
57 static const WCHAR
* VAL_HOVERHEIGHT
= L
"MouseHoverHeight";
58 static const WCHAR
* VAL_SENSITIVITY
= L
"MouseSensitivity";
60 static const WCHAR
* KEY_DESKTOP
= L
"Control Panel\\Desktop";
61 static const WCHAR
* VAL_SCRTO
= L
"ScreenSaveTimeOut";
62 static const WCHAR
* VAL_SCRNSV
= L
"SCRNSAVE.EXE";
63 static const WCHAR
* VAL_SCRACT
= L
"ScreenSaveActive";
64 static const WCHAR
* VAL_GRID
= L
"GridGranularity";
65 static const WCHAR
* VAL_DRAG
= L
"DragFullWindows";
66 static const WCHAR
* VAL_DRAGHEIGHT
= L
"DragHeight";
67 static const WCHAR
* VAL_DRAGWIDTH
= L
"DragWidth";
68 static const WCHAR
* VAL_FONTSMOOTHING
= L
"FontSmoothing";
69 static const WCHAR
* VAL_FONTSMOOTHINGTYPE
= L
"FontSmoothingType";
70 static const WCHAR
* VAL_FONTSMOOTHINGCONTRAST
= L
"FontSmoothingGamma";
71 static const WCHAR
* VAL_FONTSMOOTHINGORIENTATION
= L
"FontSmoothingOrientation";
72 static const WCHAR
* VAL_SCRLLLINES
= L
"WheelScrollLines";
73 static const WCHAR
* VAL_CLICKLOCKTIME
= L
"ClickLockTime";
74 static const WCHAR
* VAL_PAINTDESKVER
= L
"PaintDesktopVersion";
75 static const WCHAR
* VAL_CARETRATE
= L
"CursorBlinkRate";
76 #if (_WIN32_WINNT >= 0x0600)
77 static const WCHAR
* VAL_SCRLLCHARS
= L
"WheelScrollChars";
79 static const WCHAR
* VAL_USERPREFMASK
= L
"UserPreferencesMask";
81 static const WCHAR
* KEY_MDALIGN
= L
"Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows";
82 static const WCHAR
* VAL_MDALIGN
= L
"MenuDropAlignment";
84 static const WCHAR
* KEY_METRIC
= L
"Control Panel\\Desktop\\WindowMetrics";
85 static const WCHAR
* VAL_BORDER
= L
"BorderWidth";
86 static const WCHAR
* VAL_ICONSPC
= L
"IconSpacing";
87 static const WCHAR
* VAL_ICONVSPC
= L
"IconVerticalspacing";
88 static const WCHAR
* VAL_ITWRAP
= L
"IconTitleWrap";
90 static const WCHAR
* KEY_SOUND
= L
"Control Panel\\Sound";
91 static const WCHAR
* VAL_BEEP
= L
"Beep";
93 static const WCHAR
* KEY_KBD
= L
"Control Panel\\Keyboard";
94 static const WCHAR
* VAL_KBDSPD
= L
"KeyboardSpeed";
95 static const WCHAR
* VAL_KBDDELAY
= L
"KeyboardDelay";
97 static const WCHAR
* KEY_SHOWSNDS
= L
"Control Panel\\Accessibility\\ShowSounds";
98 static const WCHAR
* KEY_KDBPREF
= L
"Control Panel\\Accessibility\\Keyboard Preference";
99 static const WCHAR
* KEY_SCRREAD
= L
"Control Panel\\Accessibility\\Blind Access";
100 static const WCHAR
* VAL_ON
= L
"On";
104 /** Loading the settings ******************************************************/
108 SpiLoadDWord(PCWSTR pwszKey
, PCWSTR pwszValue
, INT iValue
)
111 if (!RegReadUserSetting(pwszKey
, pwszValue
, REG_DWORD
, &Result
, sizeof(Result
)))
120 SpiLoadInt(PCWSTR pwszKey
, PCWSTR pwszValue
, INT iValue
)
125 cbSize
= sizeof(awcBuffer
);
126 if (!RegReadUserSetting(pwszKey
, pwszValue
, REG_SZ
, awcBuffer
, cbSize
))
130 return _wtoi(awcBuffer
);
135 SpiLoadUserPrefMask(DWORD dValue
)
138 if (!RegReadUserSetting(KEY_DESKTOP
, VAL_USERPREFMASK
, REG_BINARY
, &Result
, sizeof(Result
)))
148 { // Must have the string!
149 WCHAR szApplicationName
[MAX_PATH
];
150 RtlZeroMemory(&szApplicationName
, sizeof(szApplicationName
));
151 if (!RegReadUserSetting(KEY_DESKTOP
, VAL_SCRNSV
, REG_SZ
, &szApplicationName
, sizeof(szApplicationName
)))
155 if (wcslen(szApplicationName
) == 0) return 0;
156 return SpiLoadInt(KEY_DESKTOP
, VAL_SCRTO
, 600);
161 SpiLoadMouse(PCWSTR pwszValue
, INT iValue
)
163 return SpiLoadInt(KEY_MOUSE
, pwszValue
, iValue
);
168 SpiLoadMetric(PCWSTR pwszValue
, INT iValue
)
172 iRegVal
= SpiLoadInt(KEY_METRIC
, pwszValue
, METRIC2REG(iValue
));
173 TRACE("Loaded metric setting '%S', iValue=%d(reg:%d), ret=%d(reg:%d)\n",
174 pwszValue
, iValue
, METRIC2REG(iValue
), REG2METRIC(iRegVal
), iRegVal
);
175 return REG2METRIC(iRegVal
);
180 SpiLoadFont(PLOGFONTW plfOut
, LPWSTR pwszValueName
, PLOGFONTW plfDefault
)
184 bResult
= RegReadUserSetting(KEY_METRIC
,
190 *plfOut
= *plfDefault
;
198 gspv
.ncm
.iCaptionWidth
= max(gspv
.ncm
.iCaptionWidth
, 8);
199 gspv
.ncm
.iBorderWidth
= max(gspv
.ncm
.iBorderWidth
, 1);
200 gspv
.ncm
.iScrollWidth
= max(gspv
.ncm
.iScrollWidth
, 8);
201 gspv
.ncm
.iScrollHeight
= max(gspv
.ncm
.iScrollHeight
, 8);
202 // gspv.ncm.iMenuHeight = max(gspv.ncm.iMenuHeight, gspv.tmMenuFont.tmHeight);
203 // gspv.ncm.iMenuHeight = max(gspv.ncm.iMenuHeight,
204 // 2 + gspv.tmMenuFont.tmHeight +
205 // gspv.tmMenuFont.tmExternalLeading);
206 if (gspv
.iDblClickTime
== 0) gspv
.iDblClickTime
= 500;
209 gspv
.tmMenuFont
.tmHeight
= 11;
210 gspv
.tmMenuFont
.tmExternalLeading
= 2;
212 gspv
.tmCaptionFont
.tmHeight
= 11;
213 gspv
.tmCaptionFont
.tmExternalLeading
= 2;
219 SpiUpdatePerUserSystemParameters(VOID
)
221 static LOGFONTW lf1
= {-11, 0, 0, 0, FW_NORMAL
, FALSE
, FALSE
,
222 FALSE
, ANSI_CHARSET
, 0, 0, DEFAULT_QUALITY
,
223 VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif"};
224 static LOGFONTW lf2
= {-11, 0, 0, 0, FW_BOLD
, FALSE
, FALSE
,
225 FALSE
, ANSI_CHARSET
, 0, 0, DEFAULT_QUALITY
,
226 VARIABLE_PITCH
| FF_SWISS
, L
"MS Sans Serif"};
228 TRACE("Enter SpiUpdatePerUserSystemParameters\n");
230 /* Clear the structure */
231 RtlZeroMemory(&gspv
, sizeof(gspv
));
233 /* Load mouse settings */
234 gspv
.caiMouse
.FirstThreshold
= SpiLoadMouse(VAL_MOUSE1
, 6);
235 gspv
.caiMouse
.SecondThreshold
= SpiLoadMouse(VAL_MOUSE2
, 10);
236 gspv
.caiMouse
.Acceleration
= SpiLoadMouse(VAL_MOUSE3
, 1);
237 gspv
.iMouseSpeed
= SpiLoadMouse(VAL_SENSITIVITY
, 10);
238 gspv
.bMouseBtnSwap
= SpiLoadMouse(VAL_SWAP
, 0);
239 gspv
.bSnapToDefBtn
= SpiLoadMouse(VAL_SNAPDEFBTN
, 0);
240 gspv
.iMouseTrails
= SpiLoadMouse(VAL_MOUSETRAILS
, 0);
241 gspv
.iDblClickTime
= SpiLoadMouse(VAL_DBLCLKTIME
, 500);
242 gspv
.iDblClickWidth
= SpiLoadMouse(VAL_DBLCLKWIDTH
, 4);
243 gspv
.iDblClickHeight
= SpiLoadMouse(VAL_DBLCLKHEIGHT
, 4);
244 gspv
.iMouseHoverTime
= SpiLoadMouse(VAL_HOVERTIME
, 400);
245 gspv
.iMouseHoverWidth
= SpiLoadMouse(VAL_HOVERWIDTH
, 4);
246 gspv
.iMouseHoverHeight
= SpiLoadMouse(VAL_HOVERHEIGHT
, 4);
248 /* Load keyboard settings */
249 gspv
.dwKbdSpeed
= SpiLoadInt(KEY_KBD
, VAL_KBDSPD
, 31);
250 gspv
.iKbdDelay
= SpiLoadInt(KEY_KBD
, VAL_KBDDELAY
, 1);
252 /* Load NONCLIENTMETRICS */
253 gspv
.ncm
.cbSize
= sizeof(NONCLIENTMETRICSW
);
254 gspv
.ncm
.iBorderWidth
= SpiLoadMetric(VAL_BORDER
, 1);
255 gspv
.ncm
.iScrollWidth
= SpiLoadMetric(L
"ScrollWidth", 16);
256 gspv
.ncm
.iScrollHeight
= SpiLoadMetric(L
"ScrollHeight", 16);
257 gspv
.ncm
.iCaptionWidth
= SpiLoadMetric(L
"CaptionWidth", 19);
258 gspv
.ncm
.iCaptionHeight
= SpiLoadMetric(L
"CaptionHeight", 19);
259 gspv
.ncm
.iSmCaptionWidth
= SpiLoadMetric(L
"SmCaptionWidth", 12);
260 gspv
.ncm
.iSmCaptionHeight
= SpiLoadMetric(L
"SmCaptionHeight", 14);
261 gspv
.ncm
.iMenuWidth
= SpiLoadMetric(L
"MenuWidth", 18);
262 gspv
.ncm
.iMenuHeight
= SpiLoadMetric(L
"MenuHeight", 18);
263 #if (WINVER >= 0x0600)
264 gspv
.ncm
.iPaddedBorderWidth
= SpiLoadMetric(L
"PaddedBorderWidth", 18);
266 SpiLoadFont(&gspv
.ncm
.lfCaptionFont
, L
"CaptionFont", &lf2
);
267 SpiLoadFont(&gspv
.ncm
.lfSmCaptionFont
, L
"SmCaptionFont", &lf1
);
268 SpiLoadFont(&gspv
.ncm
.lfMenuFont
, L
"MenuFont", &lf1
);
269 SpiLoadFont(&gspv
.ncm
.lfStatusFont
, L
"StatusFont", &lf1
);
270 SpiLoadFont(&gspv
.ncm
.lfMessageFont
, L
"MessageFont", &lf1
);
272 /* Load MINIMIZEDMETRICS */
273 gspv
.mm
.cbSize
= sizeof(MINIMIZEDMETRICS
);
274 gspv
.mm
.iWidth
= SpiLoadMetric(L
"MinWidth", 160);
275 gspv
.mm
.iHorzGap
= SpiLoadMetric(L
"MinHorzGap", 160);
276 gspv
.mm
.iVertGap
= SpiLoadMetric(L
"MinVertGap", 24);
277 gspv
.mm
.iArrange
= SpiLoadInt(KEY_METRIC
, L
"MinArrange", ARW_HIDE
);
279 /* Load ICONMETRICS */
280 gspv
.im
.cbSize
= sizeof(ICONMETRICSW
);
281 gspv
.im
.iHorzSpacing
= SpiLoadMetric(VAL_ICONSPC
, 64);
282 gspv
.im
.iVertSpacing
= SpiLoadMetric(VAL_ICONVSPC
, 64);
283 gspv
.im
.iTitleWrap
= SpiLoadMetric(VAL_ITWRAP
, 0);
284 SpiLoadFont(&gspv
.im
.lfFont
, L
"IconFont", &lf1
);
286 /* Load desktop settings */
287 gspv
.bDragFullWindows
= SpiLoadInt(KEY_DESKTOP
, VAL_DRAG
, 0);
288 gspv
.iWheelScrollLines
= SpiLoadInt(KEY_DESKTOP
, VAL_SCRLLLINES
, 3);
289 gspv
.dwMouseClickLockTime
= SpiLoadDWord(KEY_DESKTOP
, VAL_CLICKLOCKTIME
, 1200);
290 gpsi
->dtCaretBlink
= SpiLoadInt(KEY_DESKTOP
, VAL_CARETRATE
, 530);
291 gspv
.dwUserPrefMask
= SpiLoadUserPrefMask(UPM_DEFAULT
);
292 gspv
.bMouseClickLock
= (gspv
.dwUserPrefMask
& UPM_CLICKLOCK
) != 0;
293 gspv
.bMouseCursorShadow
= (gspv
.dwUserPrefMask
& UPM_CURSORSHADOW
) != 0;
294 gspv
.bFontSmoothing
= SpiLoadInt(KEY_DESKTOP
, VAL_FONTSMOOTHING
, 0) == 2;
295 gspv
.uiFontSmoothingType
= SpiLoadDWord(KEY_DESKTOP
, VAL_FONTSMOOTHINGTYPE
, 1);
296 gspv
.uiFontSmoothingContrast
= SpiLoadDWord(KEY_DESKTOP
, VAL_FONTSMOOTHINGCONTRAST
, 1400);
297 gspv
.uiFontSmoothingOrientation
= SpiLoadDWord(KEY_DESKTOP
, VAL_FONTSMOOTHINGORIENTATION
, 1);
298 #if (_WIN32_WINNT >= 0x0600)
299 gspv
.uiWheelScrollChars
= SpiLoadInt(KEY_DESKTOP
, VAL_SCRLLCHARS
, 3);
302 /* Some hardcoded values for now */
304 gspv
.tmCaptionFont
.tmAveCharWidth
= 6;
306 gspv
.uiFocusBorderWidth
= 1;
307 gspv
.uiFocusBorderHeight
= 1;
308 gspv
.bMenuDropAlign
= 1;
309 gspv
.dwMenuShowDelay
= 100;
310 gspv
.dwForegroundFlashCount
= 3;
312 gspv
.iScrSaverTimeout
= SpiLoadTimeOut();
313 gspv
.bScrSaverActive
= FALSE
;
314 gspv
.bScrSaverRunning
= FALSE
;
315 #if(WINVER >= 0x0600)
316 gspv
.bScrSaverSecure
= FALSE
;
319 gspv
.accesstimeout
.cbSize
= sizeof(ACCESSTIMEOUT
);
320 gspv
.filterkeys
.cbSize
= sizeof(FILTERKEYS
);
321 gspv
.togglekeys
.cbSize
= sizeof(TOGGLEKEYS
);
322 gspv
.mousekeys
.cbSize
= sizeof(MOUSEKEYS
);
323 gspv
.stickykeys
.cbSize
= sizeof(STICKYKEYS
);
324 gspv
.serialkeys
.cbSize
= sizeof(SERIALKEYS
);
325 gspv
.soundsentry
.cbSize
= sizeof(SOUNDSENTRYW
);
326 gspv
.highcontrast
.cbSize
= sizeof(HIGHCONTRASTW
);
327 gspv
.animationinfo
.cbSize
= sizeof(ANIMATIONINFO
);
329 /* Make sure we don't use broken values */
332 /* Update SystemMetrics */
335 if (gbSpiInitialized
&& gpsi
)
337 if (gspv
.bKbdPref
) gpsi
->dwSRVIFlags
|= SRVINFO_KBDPREF
;
338 if (SPITESTPREF(UPM_KEYBOARDCUES
)) gpsi
->PUSIFlags
|= PUSIF_KEYBOARDCUES
;
339 if (SPITESTPREF(UPM_COMBOBOXANIMATION
)) gpsi
->PUSIFlags
|= PUSIF_COMBOBOXANIMATION
;
340 if (SPITESTPREF(UPM_LISTBOXSMOOTHSCROLLING
)) gpsi
->PUSIFlags
|= PUSIF_LISTBOXSMOOTHSCROLLING
;
342 gdwLanguageToggleKey
= UserGetLanguageToggle();
348 SpiUpdatePerUserSystemParameters();
349 gbSpiInitialized
= TRUE
;
356 NtUserUpdatePerUserSystemParameters(
362 TRACE("Enter NtUserUpdatePerUserSystemParameters\n");
363 UserEnterExclusive();
365 SpiUpdatePerUserSystemParameters();
367 g_PaintDesktopVersion
= SpiLoadDWord(KEY_DESKTOP
, VAL_PAINTDESKVER
, 0);
369 g_PaintDesktopVersion
= FALSE
;
372 TRACE("Leave NtUserUpdatePerUserSystemParameters, returning %d\n", bResult
);
379 /** Storing the settings ******************************************************/
383 SpiStoreDWord(PCWSTR pwszKey
, PCWSTR pwszValue
, DWORD Value
)
385 RegWriteUserSetting(pwszKey
,
394 SpiStoreSz(PCWSTR pwszKey
, PCWSTR pwszValue
, PCWSTR pwsz
)
396 RegWriteUserSetting(pwszKey
,
400 (wcslen(pwsz
) + 1) * sizeof(WCHAR
));
405 SpiStoreSzInt(PCWSTR pwszKey
, PCWSTR pwszValue
, INT iValue
)
409 _itow(iValue
, awcBuffer
, 10);
410 RegWriteUserSetting(pwszKey
,
414 (wcslen(awcBuffer
) + 1) * sizeof(WCHAR
));
419 SpiStoreMetric(LPCWSTR pwszValue
, INT iValue
)
421 SpiStoreSzInt(KEY_METRIC
, pwszValue
, METRIC2REG(iValue
));
426 SpiStoreFont(PCWSTR pwszValue
, LOGFONTW
* plogfont
)
428 RegWriteUserSetting(KEY_METRIC
,
436 /** Get/Set value *************************************************************/
438 // FIXME: get rid of the flags and only use this from um. kernel can access data directly.
441 SpiMemCopy(PVOID pvDst
, PVOID pvSrc
, ULONG cbSize
, BOOL bProtect
)
443 NTSTATUS Status
= STATUS_SUCCESS
;
449 RtlCopyMemory(pvDst
, pvSrc
, cbSize
);
451 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
453 Status
= _SEH2_GetExceptionCode();
459 RtlCopyMemory(pvDst
, pvSrc
, cbSize
);
462 if (!NT_SUCCESS(Status
))
464 SetLastNtError(Status
);
465 ERR("SpiMemCopy failed, pvDst=%p, pvSrc=%p, bProtect=%d\n", pvDst
, pvSrc
, bProtect
);
468 return NT_SUCCESS(Status
);
473 SpiGet(PVOID pvParam
, PVOID pvData
, ULONG cbSize
, FLONG fl
)
475 REQ_INTERACTIVE_WINSTA(ERROR_ACCESS_DENIED
);
476 return SpiMemCopy(pvParam
, pvData
, cbSize
, fl
& SPIF_PROTECT
);
481 SpiSet(PVOID pvData
, PVOID pvParam
, ULONG cbSize
, FLONG fl
)
483 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
484 return SpiMemCopy(pvData
, pvParam
, cbSize
, fl
& SPIF_PROTECT
);
489 SpiGetEx(PVOID pvParam
, PVOID pvData
, ULONG cbSize
, FLONG fl
)
492 /* Get the cbSite member from UM memory */
493 if (!SpiSet(&cbBufSize
, pvParam
, sizeof(ULONG
), fl
))
495 /* Verify the correct size */
496 if (cbBufSize
!= cbSize
)
498 return SpiGet(pvParam
, pvData
, cbSize
, fl
);
503 SpiGetInt(PVOID pvParam
, PVOID piValue
, FLONG fl
)
505 return SpiGet(pvParam
, piValue
, sizeof(INT
), fl
);
510 SpiSetYesNo(BOOL
*pbData
, BOOL bValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
512 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
513 *pbData
= bValue
? TRUE
: FALSE
;
514 if (fl
& SPIF_UPDATEINIFILE
)
516 SpiStoreSz(pwszKey
, pwszValue
, bValue
? L
"Yes" : L
"No");
518 return (UINT_PTR
)pwszKey
;
523 SpiSetBool(BOOL
*pbData
, INT iValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
525 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
526 *pbData
= iValue
? TRUE
: FALSE
;
527 if (fl
& SPIF_UPDATEINIFILE
)
529 SpiStoreSzInt(pwszKey
, pwszValue
, iValue
);
531 return (UINT_PTR
)pwszKey
;
536 SpiSetDWord(PVOID pvData
, INT iValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
538 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
539 *(INT
*)pvData
= iValue
;
540 if (fl
& SPIF_UPDATEINIFILE
)
542 SpiStoreDWord(pwszKey
, pwszValue
, iValue
);
544 return (UINT_PTR
)pwszKey
;
549 SpiSetInt(PVOID pvData
, INT iValue
, PCWSTR pwszKey
, PCWSTR pwszValue
, FLONG fl
)
551 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
552 *(INT
*)pvData
= iValue
;
553 if (fl
& SPIF_UPDATEINIFILE
)
555 SpiStoreSzInt(pwszKey
, pwszValue
, iValue
);
557 return (UINT_PTR
)pwszKey
;
562 SpiSetMetric(PVOID pvData
, INT iValue
, PCWSTR pwszValue
, FLONG fl
)
564 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
565 *(INT
*)pvData
= iValue
;
566 if (fl
& SPIF_UPDATEINIFILE
)
568 SpiStoreMetric(pwszValue
, iValue
);
570 return (UINT_PTR
)KEY_METRIC
;
575 SpiSetUserPref(DWORD dwMask
, PVOID pvValue
, FLONG fl
)
578 BOOL bValue
= PtrToUlong(pvValue
);
580 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
582 /* Set or clear bit according to bValue */
583 gspv
.dwUserPrefMask
= bValue
? gspv
.dwUserPrefMask
| dwMask
:
584 gspv
.dwUserPrefMask
& ~dwMask
;
586 if (fl
& SPIF_UPDATEINIFILE
)
588 /* Read current value */
589 if (!RegReadUserSetting(KEY_DESKTOP
,
595 WARN("Failed to read UserPreferencesMask setting\n");
599 /* Set or clear bit according to bValue */
600 dwRegMask
= bValue
? (dwRegMask
| dwMask
) : (dwRegMask
& ~dwMask
);
602 /* write back value */
603 RegWriteUserSetting(KEY_DESKTOP
,
610 return (UINT_PTR
)KEY_DESKTOP
;
615 SpiGetUserPref(DWORD dwMask
, PVOID pvParam
, FLONG fl
)
617 INT iValue
= gspv
.dwUserPrefMask
& dwMask
? 1 : 0;
618 return SpiGetInt(pvParam
, &iValue
, fl
);
623 SpiSetWallpaper(PVOID pvParam
, FLONG fl
)
628 HBITMAP hbmp
, hOldBitmap
;
630 ULONG ulTile
, ulStyle
;
632 REQ_INTERACTIVE_WINSTA(ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
);
636 /* FIXME: Reset Wallpaper to registry value */
637 return (UINT_PTR
)KEY_DESKTOP
;
640 /* Capture UNICODE_STRING */
641 bResult
= SpiMemCopy(&ustr
, pvParam
, sizeof(ustr
), fl
& SPIF_PROTECT
);
646 if (ustr
.Length
> MAX_PATH
* sizeof(WCHAR
))
651 /* Copy the string buffer name */
652 bResult
= SpiMemCopy(gspv
.awcWallpaper
, ustr
.Buffer
, ustr
.Length
, fl
& SPIF_PROTECT
);
658 /* Update the UNICODE_STRING */
659 gspv
.ustrWallpaper
.Buffer
= gspv
.awcWallpaper
;
660 gspv
.ustrWallpaper
.MaximumLength
= MAX_PATH
* sizeof(WCHAR
);
661 gspv
.ustrWallpaper
.Length
= ustr
.Length
;
662 gspv
.awcWallpaper
[ustr
.Length
/ sizeof(WCHAR
)] = 0;
664 TRACE("SpiSetWallpaper, name=%S\n", gspv
.awcWallpaper
);
666 /* Update registry */
667 if (fl
& SPIF_UPDATEINIFILE
)
669 SpiStoreSz(KEY_DESKTOP
, L
"Wallpaper", gspv
.awcWallpaper
);
672 /* Got a filename? */
673 if (gspv
.awcWallpaper
[0] != 0)
675 /* Convert file name to nt file name */
677 ustr
.MaximumLength
= MAX_PATH
* sizeof(WCHAR
);
679 if (!W32kDosPathNameToNtPathName(gspv
.awcWallpaper
, &ustr
))
681 ERR("RtlDosPathNameToNtPathName_U failed\n");
685 /* Load the Bitmap */
686 hbmp
= UserLoadImage(ustr
.Buffer
);
689 ERR("UserLoadImage failed\n");
693 /* Try to get the size of the wallpaper */
694 if (!(psurfBmp
= SURFACE_ShareLockSurface(hbmp
)))
696 GreDeleteObject(hbmp
);
700 gspv
.cxWallpaper
= psurfBmp
->SurfObj
.sizlBitmap
.cx
;
701 gspv
.cyWallpaper
= psurfBmp
->SurfObj
.sizlBitmap
.cy
;
702 gspv
.WallpaperMode
= wmCenter
;
704 SURFACE_ShareUnlockSurface(psurfBmp
);
706 /* Change the bitmap's ownership */
707 GreSetObjectOwner(hbmp
, GDI_OBJ_HMGR_PUBLIC
);
709 /* Yes, Windows really loads the current setting from the registry. */
710 ulTile
= SpiLoadInt(KEY_DESKTOP
, L
"TileWallpaper", 0);
711 ulStyle
= SpiLoadInt(KEY_DESKTOP
, L
"WallpaperStyle", 0);
712 TRACE("SpiSetWallpaper: ulTile=%lu, ulStyle=%lu\n", ulTile
, ulStyle
);
714 /* Check the values we found in the registry */
715 if (ulTile
&& !ulStyle
)
717 gspv
.WallpaperMode
= wmTile
;
719 else if (!ulTile
&& ulStyle
)
723 gspv
.WallpaperMode
= wmStretch
;
725 else if (ulStyle
== 6)
727 gspv
.WallpaperMode
= wmFit
;
729 else if (ulStyle
== 10)
731 gspv
.WallpaperMode
= wmFill
;
737 /* Remove wallpaper */
738 gspv
.cxWallpaper
= 0;
739 gspv
.cyWallpaper
= 0;
743 /* Take care of the old wallpaper, if any */
744 hOldBitmap
= gspv
.hbmWallpaper
;
745 if(hOldBitmap
!= NULL
)
747 /* Delete the old wallpaper */
748 GreSetObjectOwner(hOldBitmap
, GDI_OBJ_HMGR_POWNED
);
749 GreDeleteObject(hOldBitmap
);
752 /* Set the new wallpaper */
753 gspv
.hbmWallpaper
= hbmp
;
755 NtUserRedrawWindow(UserGetShellWindow(), NULL
, NULL
, RDW_INVALIDATE
| RDW_ERASE
);
758 return (UINT_PTR
)KEY_DESKTOP
;
762 SpiNotifyNCMetricsChanged(VOID
)
764 PWND pwndDesktop
, pwndCurrent
;
766 USER_REFERENCE_ENTRY Ref
;
769 pwndDesktop
= UserGetDesktopWindow();
772 ahwnd
= IntWinListChildren(pwndDesktop
);
776 for (i
= 0; ahwnd
[i
]; i
++)
778 pwndCurrent
= UserGetWindowObject(ahwnd
[i
]);
782 UserRefObjectCo(pwndCurrent
, &Ref
);
783 co_WinPosSetWindowPos(pwndCurrent
, 0, pwndCurrent
->rcWindow
.left
,pwndCurrent
->rcWindow
.top
,
784 pwndCurrent
->rcWindow
.right
-pwndCurrent
->rcWindow
.left
785 ,pwndCurrent
->rcWindow
.bottom
- pwndCurrent
->rcWindow
.top
,
786 SWP_FRAMECHANGED
|SWP_NOACTIVATE
|SWP_NOCOPYBITS
|
787 SWP_NOMOVE
|SWP_NOZORDER
|SWP_NOREDRAW
);
788 UserDerefObjectCo(pwndCurrent
);
791 ExFreePoolWithTag(ahwnd
, USERTAG_WINDOWLIST
);
798 SpiGetSet(UINT uiAction
, UINT uiParam
, PVOID pvParam
, FLONG fl
)
803 return SpiGetInt(pvParam
, &gspv
.bBeep
, fl
);
806 return SpiSetYesNo(&gspv
.bBeep
, uiParam
, KEY_SOUND
, VAL_BEEP
, fl
);
809 return SpiGet(pvParam
, &gspv
.caiMouse
, 3 * sizeof(INT
), fl
);
812 if (!SpiSet(&gspv
.caiMouse
, pvParam
, 3 * sizeof(INT
), fl
))
814 if (fl
& SPIF_UPDATEINIFILE
)
816 SpiStoreSzInt(KEY_MOUSE
, VAL_MOUSE1
, gspv
.caiMouse
.FirstThreshold
);
817 SpiStoreSzInt(KEY_MOUSE
, VAL_MOUSE2
, gspv
.caiMouse
.SecondThreshold
);
818 SpiStoreSzInt(KEY_MOUSE
, VAL_MOUSE3
, gspv
.caiMouse
.Acceleration
);
820 return (UINT_PTR
)KEY_MOUSE
;
823 return SpiGetInt(pvParam
, &gspv
.ncm
.iBorderWidth
, fl
);
826 uiParam
= max(uiParam
, 1);
827 return SpiSetInt(&gspv
.ncm
.iBorderWidth
, uiParam
, KEY_METRIC
, VAL_BORDER
, fl
);
829 case SPI_GETKEYBOARDSPEED
:
830 return SpiGetInt(pvParam
, &gspv
.dwKbdSpeed
, fl
);
832 case SPI_SETKEYBOARDSPEED
:
833 return SpiSetInt(&gspv
.dwKbdSpeed
, uiParam
, KEY_KBD
, VAL_KBDSPD
, fl
);
836 ERR("SPI_LANGDRIVER is unimplemented\n");
839 case SPI_GETSCREENSAVETIMEOUT
:
840 return SpiGetInt(pvParam
, &gspv
.iScrSaverTimeout
, fl
);
842 case SPI_SETSCREENSAVETIMEOUT
:
843 return SpiSetInt(&gspv
.iScrSaverTimeout
, uiParam
, KEY_DESKTOP
, VAL_SCRTO
, fl
);
845 case SPI_GETSCREENSAVEACTIVE
:
846 return SpiGetInt(pvParam
, &gspv
.bScrSaverActive
, fl
);
848 case SPI_SETSCREENSAVEACTIVE
:
849 return SpiSetInt(&gspv
.bScrSaverActive
, uiParam
, KEY_DESKTOP
, VAL_SCRACT
, fl
);
851 case SPI_GETGRIDGRANULARITY
:
852 return SpiGetInt(pvParam
, &gspv
.uiGridGranularity
, fl
);
854 case SPI_SETGRIDGRANULARITY
:
855 return SpiSetInt(&gspv
.uiGridGranularity
, uiParam
, KEY_DESKTOP
, VAL_GRID
, fl
);
857 case SPI_GETDESKWALLPAPER
:
858 uiParam
= min(uiParam
, gspv
.ustrWallpaper
.Length
+ 1UL);
859 return SpiGet(pvParam
, gspv
.awcWallpaper
, uiParam
, fl
);
861 case SPI_SETDESKWALLPAPER
:
862 return SpiSetWallpaper(pvParam
, fl
);
864 case SPI_SETDESKPATTERN
:
865 ERR("SPI_SETDESKPATTERN is unimplemented\n");
868 case SPI_GETKEYBOARDDELAY
:
869 return SpiGetInt(pvParam
, &gspv
.iKbdDelay
, fl
);
871 case SPI_SETKEYBOARDDELAY
:
872 return SpiSetInt(&gspv
.iKbdDelay
, uiParam
, KEY_KBD
, VAL_KBDDELAY
, fl
);
874 case SPI_ICONHORIZONTALSPACING
:
877 return SpiGetInt(pvParam
, &gspv
.im
.iHorzSpacing
, fl
);
879 uiParam
= max(uiParam
, 32);
880 return SpiSetMetric(&gspv
.im
.iHorzSpacing
, uiParam
, VAL_ICONSPC
, fl
);
882 case SPI_ICONVERTICALSPACING
:
885 return SpiGetInt(pvParam
, &gspv
.im
.iVertSpacing
, fl
);
887 uiParam
= max(uiParam
, 32);
888 return SpiSetMetric(&gspv
.im
.iVertSpacing
, uiParam
, VAL_ICONVSPC
, fl
);
890 case SPI_GETICONTITLEWRAP
:
891 return SpiGetInt(pvParam
, &gspv
.im
.iTitleWrap
, fl
);
893 case SPI_SETICONTITLEWRAP
:
894 return SpiSetInt(&gspv
.im
.iTitleWrap
, uiParam
, KEY_METRIC
, VAL_ITWRAP
, fl
);
896 case SPI_GETMENUDROPALIGNMENT
:
897 return SpiGetInt(pvParam
, &gspv
.bMenuDropAlign
, fl
);
899 case SPI_SETMENUDROPALIGNMENT
:
900 return SpiSetBool(&gspv
.bMenuDropAlign
, uiParam
, KEY_MDALIGN
, VAL_MDALIGN
, fl
);
902 case SPI_SETDOUBLECLKWIDTH
:
903 return SpiSetInt(&gspv
.iDblClickWidth
, uiParam
, KEY_MOUSE
, VAL_DBLCLKWIDTH
, fl
);
905 case SPI_SETDOUBLECLKHEIGHT
:
906 return SpiSetInt(&gspv
.iDblClickHeight
, uiParam
, KEY_MOUSE
, VAL_DBLCLKHEIGHT
, fl
);
908 case SPI_GETICONTITLELOGFONT
:
909 return SpiGet(pvParam
, &gspv
.im
.lfFont
, sizeof(LOGFONTW
), fl
);
911 case SPI_SETICONTITLELOGFONT
:
912 if (!SpiSet(&gspv
.im
.lfFont
, pvParam
, sizeof(LOGFONTW
), fl
))
914 if (fl
& SPIF_UPDATEINIFILE
)
916 SpiStoreFont(L
"IconFont", &gspv
.im
.lfFont
);
918 return (UINT_PTR
)KEY_METRIC
;
920 case SPI_SETDOUBLECLICKTIME
:
921 return SpiSetInt(&gspv
.iDblClickTime
, uiParam
, KEY_MOUSE
, VAL_DBLCLKTIME
, fl
);
923 case SPI_SETMOUSEBUTTONSWAP
:
924 return SpiSetInt(&gspv
.bMouseBtnSwap
, uiParam
, KEY_MOUSE
, VAL_SWAP
, fl
);
926 case SPI_GETFASTTASKSWITCH
:
927 return SpiGetInt(pvParam
, &gspv
.bFastTaskSwitch
, fl
);
929 case SPI_SETFASTTASKSWITCH
:
930 /* According to Winetest this one is unimplemented */
933 case SPI_GETDRAGFULLWINDOWS
:
934 return SpiGetInt(pvParam
, &gspv
.bDragFullWindows
, fl
);
936 case SPI_SETDRAGFULLWINDOWS
:
937 return SpiSetInt(&gspv
.bDragFullWindows
, uiParam
, KEY_DESKTOP
, VAL_DRAG
, fl
);
939 case SPI_GETNONCLIENTMETRICS
:
941 return SpiGet(pvParam
, &gspv
.ncm
, sizeof(NONCLIENTMETRICSW
), fl
);
944 case SPI_SETNONCLIENTMETRICS
:
946 LPNONCLIENTMETRICSW metrics
= (LPNONCLIENTMETRICSW
)pvParam
;
948 /* Fixup user's structure size */
949 metrics
->cbSize
= sizeof(NONCLIENTMETRICSW
);
951 if (!SpiSet(&gspv
.ncm
, metrics
, sizeof(NONCLIENTMETRICSW
), fl
))
954 if (fl
& SPIF_UPDATEINIFILE
)
956 SpiStoreMetric(VAL_BORDER
, gspv
.ncm
.iBorderWidth
);
957 SpiStoreMetric(L
"ScrollWidth", gspv
.ncm
.iScrollWidth
);
958 SpiStoreMetric(L
"ScrollHeight", gspv
.ncm
.iScrollHeight
);
959 SpiStoreMetric(L
"CaptionWidth", gspv
.ncm
.iCaptionWidth
);
960 SpiStoreMetric(L
"CaptionHeight", gspv
.ncm
.iCaptionHeight
);
961 SpiStoreMetric(L
"SmCaptionWidth", gspv
.ncm
.iSmCaptionWidth
);
962 SpiStoreMetric(L
"SmCaptionHeight", gspv
.ncm
.iSmCaptionHeight
);
963 SpiStoreMetric(L
"MenuWidth", gspv
.ncm
.iMenuWidth
);
964 SpiStoreMetric(L
"MenuHeight", gspv
.ncm
.iMenuHeight
);
965 #if (WINVER >= 0x0600)
966 SpiStoreMetric(L
"PaddedBorderWidth", gspv
.ncm
.iPaddedBorderWidth
);
968 SpiStoreFont(L
"CaptionFont", &gspv
.ncm
.lfCaptionFont
);
969 SpiStoreFont(L
"SmCaptionFont", &gspv
.ncm
.lfSmCaptionFont
);
970 SpiStoreFont(L
"MenuFont", &gspv
.ncm
.lfMenuFont
);
971 SpiStoreFont(L
"StatusFont", &gspv
.ncm
.lfStatusFont
);
972 SpiStoreFont(L
"MessageFont", &gspv
.ncm
.lfMessageFont
);
975 if(!SpiNotifyNCMetricsChanged())
978 return (UINT_PTR
)KEY_METRIC
;
981 case SPI_GETMINIMIZEDMETRICS
:
983 return SpiGet(pvParam
, &gspv
.mm
, sizeof(MINIMIZEDMETRICS
), fl
);
986 case SPI_SETMINIMIZEDMETRICS
:
988 LPMINIMIZEDMETRICS metrics
= (LPMINIMIZEDMETRICS
)pvParam
;
990 /* Fixup user's structure size */
991 metrics
->cbSize
= sizeof(MINIMIZEDMETRICS
);
993 if (!SpiSet(&gspv
.mm
, metrics
, sizeof(MINIMIZEDMETRICS
), fl
))
996 gspv
.mm
.iWidth
= max(0, gspv
.mm
.iWidth
);
997 gspv
.mm
.iHorzGap
= max(0, gspv
.mm
.iHorzGap
);
998 gspv
.mm
.iVertGap
= max(0, gspv
.mm
.iVertGap
);
999 gspv
.mm
.iArrange
= gspv
.mm
.iArrange
& 0xf;
1001 if (fl
& SPIF_UPDATEINIFILE
)
1003 SpiStoreMetric(L
"MinWidth", gspv
.mm
.iWidth
);
1004 SpiStoreMetric(L
"MinHorzGap", gspv
.mm
.iHorzGap
);
1005 SpiStoreMetric(L
"MinVertGap", gspv
.mm
.iVertGap
);
1006 SpiStoreMetric(L
"MinArrange", gspv
.mm
.iArrange
);
1009 return (UINT_PTR
)KEY_METRIC
;
1012 case SPI_GETICONMETRICS
:
1014 return SpiGet(pvParam
, &gspv
.im
, sizeof(ICONMETRICSW
), fl
);
1017 case SPI_SETICONMETRICS
:
1019 LPICONMETRICSW metrics
= (LPICONMETRICSW
)pvParam
;
1021 /* Fixup user's structure size */
1022 metrics
->cbSize
= sizeof(ICONMETRICSW
);
1024 if (!SpiSet(&gspv
.im
, metrics
, sizeof(ICONMETRICSW
), fl
))
1027 if (fl
& SPIF_UPDATEINIFILE
)
1029 SpiStoreMetric(VAL_ICONSPC
, gspv
.im
.iHorzSpacing
);
1030 SpiStoreMetric(VAL_ICONVSPC
, gspv
.im
.iVertSpacing
);
1031 SpiStoreMetric(VAL_ITWRAP
, gspv
.im
.iTitleWrap
);
1032 SpiStoreFont(L
"IconFont", &gspv
.im
.lfFont
);
1034 return (UINT_PTR
)KEY_METRIC
;
1037 case SPI_GETWORKAREA
:
1039 PMONITOR pmonitor
= UserGetPrimaryMonitor();
1044 return SpiGet(pvParam
, &pmonitor
->rcWork
, sizeof(RECTL
), fl
);
1047 case SPI_SETWORKAREA
:
1049 /* FIXME: We should set the work area of the monitor
1050 that contains the specified rectangle */
1051 PMONITOR pmonitor
= UserGetPrimaryMonitor();
1057 if (!SpiSet(&rcWorkArea
, pvParam
, sizeof(RECTL
), fl
))
1060 /* Verify the new values */
1061 if (rcWorkArea
.left
< 0 ||
1062 rcWorkArea
.top
< 0 ||
1063 rcWorkArea
.right
> gpsi
->aiSysMet
[SM_CXSCREEN
] ||
1064 rcWorkArea
.bottom
> gpsi
->aiSysMet
[SM_CYSCREEN
] ||
1065 rcWorkArea
.right
<= rcWorkArea
.left
||
1066 rcWorkArea
.bottom
<= rcWorkArea
.top
)
1069 pmonitor
->rcWork
= rcWorkArea
;
1070 if (fl
& SPIF_UPDATEINIFILE
)
1072 // FIXME: What to do?
1074 return (UINT_PTR
)KEY_DESKTOP
;
1077 case SPI_SETPENWINDOWS
:
1078 ERR("SPI_SETPENWINDOWS is unimplemented\n");
1081 case SPI_GETFILTERKEYS
:
1083 LPFILTERKEYS FilterKeys
= (LPFILTERKEYS
)pvParam
;
1085 if (uiParam
!= 0 && uiParam
!= sizeof(FILTERKEYS
))
1088 if (!FilterKeys
|| FilterKeys
->cbSize
!= sizeof(FILTERKEYS
))
1091 return SpiGet(pvParam
, &gspv
.filterkeys
, sizeof(FILTERKEYS
), fl
);
1094 case SPI_SETFILTERKEYS
:
1096 LPFILTERKEYS FilterKeys
= (LPFILTERKEYS
)pvParam
;
1098 if (uiParam
!= 0 && uiParam
!= sizeof(FILTERKEYS
))
1101 if (!FilterKeys
|| FilterKeys
->cbSize
!= sizeof(FILTERKEYS
))
1104 if (!SpiSet(&gspv
.filterkeys
, pvParam
, sizeof(FILTERKEYS
), fl
))
1107 if (fl
& SPIF_UPDATEINIFILE
)
1109 // FIXME: What to do?
1111 return (UINT_PTR
)KEY_DESKTOP
;
1114 case SPI_GETTOGGLEKEYS
:
1116 LPTOGGLEKEYS ToggleKeys
= (LPTOGGLEKEYS
)pvParam
;
1118 if (uiParam
!= 0 && uiParam
!= sizeof(TOGGLEKEYS
))
1121 if (!ToggleKeys
|| ToggleKeys
->cbSize
!= sizeof(TOGGLEKEYS
))
1124 return SpiGet(pvParam
, &gspv
.togglekeys
, sizeof(TOGGLEKEYS
), fl
);
1127 case SPI_SETTOGGLEKEYS
:
1129 LPTOGGLEKEYS ToggleKeys
= (LPTOGGLEKEYS
)pvParam
;
1131 if (uiParam
!= 0 && uiParam
!= sizeof(TOGGLEKEYS
))
1134 if (!ToggleKeys
|| ToggleKeys
->cbSize
!= sizeof(TOGGLEKEYS
))
1137 if (!SpiSet(&gspv
.togglekeys
, pvParam
, sizeof(TOGGLEKEYS
), fl
))
1140 if (fl
& SPIF_UPDATEINIFILE
)
1142 // FIXME: What to do?
1144 return (UINT_PTR
)KEY_DESKTOP
;
1147 case SPI_GETMOUSEKEYS
:
1149 LPMOUSEKEYS MouseKeys
= (LPMOUSEKEYS
)pvParam
;
1151 if (uiParam
!= 0 && uiParam
!= sizeof(MOUSEKEYS
))
1154 if (!MouseKeys
|| MouseKeys
->cbSize
!= sizeof(MOUSEKEYS
))
1157 return SpiGet(pvParam
, &gspv
.mousekeys
, sizeof(MOUSEKEYS
), fl
);
1160 case SPI_SETMOUSEKEYS
:
1162 LPMOUSEKEYS MouseKeys
= (LPMOUSEKEYS
)pvParam
;
1164 if (uiParam
!= 0 && uiParam
!= sizeof(MOUSEKEYS
))
1167 if (!MouseKeys
|| MouseKeys
->cbSize
!= sizeof(MOUSEKEYS
))
1170 if (!SpiSet(&gspv
.mousekeys
, pvParam
, sizeof(MOUSEKEYS
), fl
))
1173 if (fl
& SPIF_UPDATEINIFILE
)
1175 // FIXME: What to do?
1177 return (UINT_PTR
)KEY_DESKTOP
;
1180 case SPI_GETSHOWSOUNDS
:
1181 return SpiGetInt(pvParam
, &gspv
.bShowSounds
, fl
);
1183 case SPI_SETSHOWSOUNDS
:
1184 return SpiSetBool(&gspv
.bShowSounds
, uiParam
, KEY_SHOWSNDS
, VAL_ON
, fl
);
1186 case SPI_GETSTICKYKEYS
:
1188 LPSTICKYKEYS StickyKeys
= (LPSTICKYKEYS
)pvParam
;
1190 if (uiParam
!= 0 && uiParam
!= sizeof(STICKYKEYS
))
1193 if (!StickyKeys
|| StickyKeys
->cbSize
!= sizeof(STICKYKEYS
))
1196 return SpiGetEx(pvParam
, &gspv
.stickykeys
, sizeof(STICKYKEYS
), fl
);
1199 case SPI_SETSTICKYKEYS
:
1201 LPSTICKYKEYS StickyKeys
= (LPSTICKYKEYS
)pvParam
;
1203 if (uiParam
!= 0 && uiParam
!= sizeof(STICKYKEYS
))
1206 if (!StickyKeys
|| StickyKeys
->cbSize
!= sizeof(STICKYKEYS
))
1209 if (!SpiSet(&gspv
.stickykeys
, pvParam
, sizeof(STICKYKEYS
), fl
))
1212 if (fl
& SPIF_UPDATEINIFILE
)
1214 // FIXME: What to do?
1216 return (UINT_PTR
)KEY_DESKTOP
;
1219 case SPI_GETACCESSTIMEOUT
:
1221 LPACCESSTIMEOUT AccessTimeout
= (LPACCESSTIMEOUT
)pvParam
;
1223 if (uiParam
!= 0 && uiParam
!= sizeof(ACCESSTIMEOUT
))
1226 if (!AccessTimeout
|| AccessTimeout
->cbSize
!= sizeof(ACCESSTIMEOUT
))
1229 return SpiGetEx(pvParam
, &gspv
.accesstimeout
, sizeof(ACCESSTIMEOUT
), fl
);
1232 case SPI_SETACCESSTIMEOUT
:
1234 LPACCESSTIMEOUT AccessTimeout
= (LPACCESSTIMEOUT
)pvParam
;
1236 if (uiParam
!= 0 && uiParam
!= sizeof(ACCESSTIMEOUT
))
1241 if (!AccessTimeout
|| AccessTimeout
->cbSize
!= sizeof(ACCESSTIMEOUT
))
1246 if (!SpiSet(&gspv
.accesstimeout
, pvParam
, sizeof(ACCESSTIMEOUT
), fl
))
1249 if (fl
& SPIF_UPDATEINIFILE
)
1251 // FIXME: What to do?
1253 return (UINT_PTR
)KEY_DESKTOP
;
1256 case SPI_GETSERIALKEYS
:
1258 LPSERIALKEYS SerialKeys
= (LPSERIALKEYS
)pvParam
;
1260 if (uiParam
!= 0 && uiParam
!= sizeof(SERIALKEYS
))
1263 if (!SerialKeys
|| SerialKeys
->cbSize
!= sizeof(SERIALKEYS
))
1266 return SpiGet(pvParam
, &gspv
.serialkeys
, sizeof(SERIALKEYS
), fl
);
1269 case SPI_SETSERIALKEYS
:
1271 LPSERIALKEYS SerialKeys
= (LPSERIALKEYS
)pvParam
;
1273 if (uiParam
!= 0 && uiParam
!= sizeof(SERIALKEYS
))
1276 if (!SerialKeys
|| SerialKeys
->cbSize
!= sizeof(SERIALKEYS
))
1279 if (!SpiSet(&gspv
.serialkeys
, pvParam
, sizeof(SERIALKEYS
), fl
))
1282 if (fl
& SPIF_UPDATEINIFILE
)
1284 // FIXME: What to do?
1286 return (UINT_PTR
)KEY_DESKTOP
;
1289 case SPI_GETSOUNDSENTRY
:
1291 LPSOUNDSENTRYW SoundsEntry
= (LPSOUNDSENTRYW
)pvParam
;
1293 if (uiParam
!= 0 && uiParam
!= sizeof(SOUNDSENTRYW
))
1296 if (!SoundsEntry
|| SoundsEntry
->cbSize
!= sizeof(SOUNDSENTRYW
))
1299 return SpiGet(pvParam
, &gspv
.soundsentry
, sizeof(SOUNDSENTRYW
), fl
);
1302 case SPI_SETSOUNDSENTRY
:
1304 LPSOUNDSENTRYW SoundsEntry
= (LPSOUNDSENTRYW
)pvParam
;
1306 if (uiParam
!= 0 && uiParam
!= sizeof(SOUNDSENTRYW
))
1309 if (!SoundsEntry
|| SoundsEntry
->cbSize
!= sizeof(SOUNDSENTRYW
))
1312 if (!SpiSet(&gspv
.soundsentry
, pvParam
, sizeof(SOUNDSENTRYW
), fl
))
1315 if (fl
& SPIF_UPDATEINIFILE
)
1317 // FIXME: What to do?
1319 return (UINT_PTR
)KEY_DESKTOP
;
1322 case SPI_GETHIGHCONTRAST
:
1324 LPHIGHCONTRASTW highcontrast
= (LPHIGHCONTRASTW
)pvParam
;
1326 if (uiParam
!= 0 && uiParam
!= sizeof(HIGHCONTRASTW
))
1329 if (!highcontrast
|| highcontrast
->cbSize
!= sizeof(HIGHCONTRASTW
))
1332 return SpiGet(pvParam
, &gspv
.highcontrast
, sizeof(HIGHCONTRASTW
), fl
);
1335 case SPI_SETHIGHCONTRAST
:
1337 LPHIGHCONTRASTW highcontrast
= (LPHIGHCONTRASTW
)pvParam
;
1339 if (uiParam
!= 0 && uiParam
!= sizeof(HIGHCONTRASTW
))
1342 if (!highcontrast
|| highcontrast
->cbSize
!= sizeof(HIGHCONTRASTW
))
1345 if (!SpiSet(&gspv
.highcontrast
, pvParam
, sizeof(HIGHCONTRASTW
), fl
))
1348 if (fl
& SPIF_UPDATEINIFILE
)
1350 // FIXME: What to do?
1352 return (UINT_PTR
)KEY_DESKTOP
;
1355 case SPI_GETKEYBOARDPREF
:
1356 return SpiGetInt(pvParam
, &gspv
.bKbdPref
, fl
);
1358 case SPI_SETKEYBOARDPREF
:
1359 return SpiSetBool(&gspv
.bKbdPref
, uiParam
, KEY_KDBPREF
, VAL_ON
, fl
);
1361 case SPI_GETSCREENREADER
:
1362 return SpiGetInt(pvParam
, &gspv
.bScreenReader
, fl
);
1364 case SPI_SETSCREENREADER
:
1365 return SpiSetBool(&gspv
.bScreenReader
, uiParam
, KEY_SCRREAD
, VAL_ON
, fl
);
1367 case SPI_GETANIMATION
:
1368 return SpiGet(pvParam
, &gspv
.animationinfo
, sizeof(ANIMATIONINFO
), fl
);
1370 case SPI_SETANIMATION
:
1371 if (!SpiSet(&gspv
.animationinfo
, pvParam
, sizeof(ANIMATIONINFO
), fl
))
1373 if (fl
& SPIF_UPDATEINIFILE
)
1375 // FIXME: What to do?
1377 return (UINT_PTR
)KEY_DESKTOP
;
1379 case SPI_GETFONTSMOOTHING
:
1380 return SpiGetInt(pvParam
, &gspv
.bFontSmoothing
, fl
);
1382 case SPI_SETFONTSMOOTHING
:
1383 gspv
.bFontSmoothing
= (uiParam
== 2);
1384 if (fl
& SPIF_UPDATEINIFILE
)
1386 SpiStoreSz(KEY_DESKTOP
, VAL_FONTSMOOTHING
, (uiParam
== 2) ? L
"2" : L
"0");
1388 return (UINT_PTR
)KEY_DESKTOP
;
1390 case SPI_SETDRAGWIDTH
:
1391 return SpiSetInt(&gspv
.iDragWidth
, uiParam
, KEY_DESKTOP
, VAL_DRAGWIDTH
, fl
);
1393 case SPI_SETDRAGHEIGHT
:
1394 return SpiSetInt(&gspv
.iDragHeight
, uiParam
, KEY_DESKTOP
, VAL_DRAGHEIGHT
, fl
);
1396 case SPI_SETHANDHELD
:
1397 return SpiSetBool(&gspv
.bHandHeld
, uiParam
, KEY_DESKTOP
, L
"HandHeld", fl
);
1399 case SPI_GETLOWPOWERTIMEOUT
:
1400 return SpiGetInt(pvParam
, &gspv
.iLowPwrTimeout
, fl
);
1402 case SPI_GETPOWEROFFTIMEOUT
:
1403 return SpiGetInt(pvParam
, &gspv
.iPwrOffTimeout
, fl
);
1405 case SPI_SETLOWPOWERTIMEOUT
:
1406 return SpiSetInt(&gspv
.iLowPwrTimeout
, uiParam
, KEY_DESKTOP
, L
"LowPowerTimeOut", fl
);
1408 case SPI_SETPOWEROFFTIMEOUT
:
1409 return SpiSetInt(&gspv
.iPwrOffTimeout
, uiParam
, KEY_DESKTOP
, L
"PowerOffTimeOut", fl
);
1411 case SPI_GETLOWPOWERACTIVE
:
1412 return SpiGetInt(pvParam
, &gspv
.iPwrOffTimeout
, fl
);
1414 case SPI_GETPOWEROFFACTIVE
:
1415 return SpiGetInt(pvParam
, &gspv
.bPwrOffActive
, fl
);
1417 case SPI_SETLOWPOWERACTIVE
:
1418 return SpiSetBool(&gspv
.bLowPwrActive
, uiParam
, KEY_DESKTOP
, L
"LowPowerActive", fl
);
1420 case SPI_SETPOWEROFFACTIVE
:
1421 return SpiSetBool(&gspv
.bPwrOffActive
, uiParam
, KEY_DESKTOP
, L
"PowerOffActive", fl
);
1423 case SPI_SETCURSORS
:
1424 ERR("SPI_SETCURSORS is unimplemented\n");
1428 ERR("SPI_SETICONS is unimplemented\n");
1431 case SPI_GETDEFAULTINPUTLANG
:
1432 if (!gspklBaseLayout
)
1435 return SpiGet(pvParam
, &gspklBaseLayout
->hkl
, sizeof(HKL
), fl
);
1437 case SPI_SETDEFAULTINPUTLANG
:
1441 /* Note: SPIF_UPDATEINIFILE is not supported */
1442 if ((fl
& SPIF_UPDATEINIFILE
) || !SpiSet(&hkl
, pvParam
, sizeof(hkl
), fl
))
1445 return UserSetDefaultInputLang(hkl
);
1448 case SPI_SETLANGTOGGLE
:
1449 gdwLanguageToggleKey
= UserGetLanguageToggle();
1450 return gdwLanguageToggleKey
;
1453 case SPI_GETWINDOWSEXTENSION
:
1454 ERR("SPI_GETWINDOWSEXTENSION is unimplemented\n");
1457 case SPI_GETMOUSETRAILS
:
1458 return SpiGetInt(pvParam
, &gspv
.iMouseTrails
, fl
);
1460 case SPI_SETMOUSETRAILS
:
1461 return SpiSetInt(&gspv
.iMouseTrails
, uiParam
, KEY_MOUSE
, VAL_MOUSETRAILS
, fl
);
1463 case SPI_GETSNAPTODEFBUTTON
:
1464 return SpiGetInt(pvParam
, &gspv
.bSnapToDefBtn
, fl
);
1466 case SPI_SETSNAPTODEFBUTTON
:
1467 return SpiSetBool(&gspv
.bSnapToDefBtn
, uiParam
, KEY_MOUSE
, VAL_SNAPDEFBTN
, fl
);
1469 case SPI_GETMOUSEHOVERWIDTH
:
1470 return SpiGetInt(pvParam
, &gspv
.iMouseHoverWidth
, fl
);
1472 case SPI_SETMOUSEHOVERWIDTH
:
1473 return SpiSetInt(&gspv
.iMouseHoverWidth
, uiParam
, KEY_MOUSE
, VAL_HOVERWIDTH
, fl
);
1475 case SPI_GETMOUSEHOVERHEIGHT
:
1476 return SpiGetInt(pvParam
, &gspv
.iMouseHoverHeight
, fl
);
1478 case SPI_SETMOUSEHOVERHEIGHT
:
1479 return SpiSetInt(&gspv
.iMouseHoverHeight
, uiParam
, KEY_MOUSE
, VAL_HOVERHEIGHT
, fl
);
1481 case SPI_GETMOUSEHOVERTIME
:
1482 return SpiGetInt(pvParam
, &gspv
.iMouseHoverTime
, fl
);
1484 case SPI_SETMOUSEHOVERTIME
:
1485 /* See http://msdn2.microsoft.com/en-us/library/ms724947.aspx
1486 * copy text from it, if some agument why xp and 2003 behovir diffent
1487 * only if they do not have SP install
1488 * " Windows Server 2003 and Windows XP: The operating system does not
1489 * enforce the use of USER_TIMER_MAXIMUM and USER_TIMER_MINIMUM until
1490 * Windows Server 2003 SP1 and Windows XP SP2 "
1492 return SpiSetInt(&gspv
.iMouseHoverTime
, uiParam
, KEY_MOUSE
, VAL_HOVERTIME
, fl
);
1494 case SPI_GETWHEELSCROLLLINES
:
1495 return SpiGetInt(pvParam
, &gspv
.iWheelScrollLines
, fl
);
1497 case SPI_SETWHEELSCROLLLINES
:
1498 return SpiSetInt(&gspv
.iWheelScrollLines
, uiParam
, KEY_DESKTOP
, VAL_SCRLLLINES
, fl
);
1500 case SPI_GETMENUSHOWDELAY
:
1501 return SpiGetInt(pvParam
, &gspv
.dwMenuShowDelay
, fl
);
1503 case SPI_SETMENUSHOWDELAY
:
1504 return SpiSetInt(&gspv
.dwMenuShowDelay
, uiParam
, KEY_DESKTOP
, L
"MenuShowDelay", fl
);
1506 #if (_WIN32_WINNT >= 0x0600)
1507 case SPI_GETWHEELSCROLLCHARS
:
1508 return SpiGetInt(pvParam
, &gspv
.uiWheelScrollChars
, fl
);
1510 case SPI_SETWHEELSCROLLCHARS
:
1511 return SpiSetInt(&gspv
.uiWheelScrollChars
, uiParam
, KEY_DESKTOP
, VAL_SCRLLCHARS
, fl
);
1513 case SPI_GETSHOWIMEUI
:
1514 return SpiGetInt(pvParam
, &gspv
.bShowImeUi
, fl
);
1516 case SPI_SETSHOWIMEUI
:
1517 return SpiSetBool(&gspv
.bShowImeUi
, uiParam
, KEY_DESKTOP
, L
"", fl
);
1519 case SPI_GETMOUSESPEED
:
1520 return SpiGetInt(pvParam
, &gspv
.iMouseSpeed
, fl
);
1522 case SPI_SETMOUSESPEED
:
1524 /* Allowed range is [1:20] */
1525 if ((INT_PTR
)pvParam
< 1 || (INT_PTR
)pvParam
> 20)
1528 return SpiSetInt(&gspv
.iMouseSpeed
, (INT_PTR
)pvParam
, KEY_MOUSE
, VAL_SENSITIVITY
, fl
);
1531 case SPI_GETSCREENSAVERRUNNING
:
1532 return SpiGetInt(pvParam
, &gspv
.bScrSaverRunning
, fl
);
1534 case SPI_SETSCREENSAVERRUNNING
:
1535 // FIXME: also return value?
1536 return SpiSetBool(&gspv
.bScrSaverRunning
, uiParam
, KEY_MOUSE
, L
"", fl
);
1538 #if(WINVER >= 0x0600)
1539 case SPI_GETAUDIODESCRIPTION
:
1540 return SpiGet(pvParam
, &gspv
.audiodescription
, sizeof(AUDIODESCRIPTION
), fl
);
1542 case SPI_SETAUDIODESCRIPTION
:
1543 ERR("SPI_SETAUDIODESCRIPTION is unimplemented\n");
1546 case SPI_GETSCREENSAVESECURE
:
1547 return SpiGetInt(pvParam
, &gspv
.bScrSaverSecure
, fl
);
1549 case SPI_SETSCREENSAVESECURE
:
1550 return SpiSetBool(&gspv
.bScrSaverSecure
, uiParam
, KEY_DESKTOP
, L
"ScreenSaverIsSecure", fl
);
1553 case SPI_GETACTIVEWINDOWTRACKING
:
1554 return SpiGetUserPref(UPM_ACTIVEWINDOWTRACKING
, pvParam
, fl
);
1556 case SPI_SETACTIVEWINDOWTRACKING
:
1557 return SpiSetUserPref(UPM_ACTIVEWINDOWTRACKING
, pvParam
, fl
);
1559 case SPI_GETMENUANIMATION
:
1560 return SpiGetUserPref(UPM_MENUANIMATION
, pvParam
, fl
);
1562 case SPI_SETMENUANIMATION
:
1563 return SpiSetUserPref(UPM_MENUANIMATION
, pvParam
, fl
);
1565 case SPI_GETCOMBOBOXANIMATION
:
1566 return SpiGetUserPref(UPM_COMBOBOXANIMATION
, pvParam
, fl
);
1568 case SPI_SETCOMBOBOXANIMATION
:
1569 return SpiSetUserPref(UPM_COMBOBOXANIMATION
, pvParam
, fl
);
1571 case SPI_GETLISTBOXSMOOTHSCROLLING
:
1572 return SpiGetUserPref(UPM_LISTBOXSMOOTHSCROLLING
, pvParam
, fl
);
1574 case SPI_SETLISTBOXSMOOTHSCROLLING
:
1575 return SpiSetUserPref(UPM_LISTBOXSMOOTHSCROLLING
, pvParam
, fl
);
1577 case SPI_GETGRADIENTCAPTIONS
:
1578 return SpiGetUserPref(UPM_GRADIENTCAPTIONS
, pvParam
, fl
);
1580 case SPI_SETGRADIENTCAPTIONS
:
1581 return SpiSetUserPref(UPM_GRADIENTCAPTIONS
, pvParam
, fl
);
1583 case SPI_GETKEYBOARDCUES
:
1584 return SpiGetUserPref(UPM_KEYBOARDCUES
, pvParam
, fl
);
1586 case SPI_SETKEYBOARDCUES
:
1587 return SpiSetUserPref(UPM_KEYBOARDCUES
, pvParam
, fl
);
1589 case SPI_GETACTIVEWNDTRKZORDER
:
1590 return SpiGetUserPref(UPM_ACTIVEWNDTRKZORDER
, pvParam
, fl
);
1592 case SPI_SETACTIVEWNDTRKZORDER
:
1593 return SpiSetUserPref(UPM_ACTIVEWNDTRKZORDER
, pvParam
, fl
);
1595 case SPI_GETHOTTRACKING
:
1596 return SpiGetUserPref(UPM_HOTTRACKING
, pvParam
, fl
);
1598 case SPI_SETHOTTRACKING
:
1599 return SpiSetUserPref(UPM_HOTTRACKING
, pvParam
, fl
);
1601 case SPI_GETMENUFADE
:
1602 return SpiGetUserPref(UPM_MENUFADE
, pvParam
, fl
);
1604 case SPI_SETMENUFADE
:
1605 return SpiSetUserPref(UPM_MENUFADE
, pvParam
, fl
);
1607 case SPI_GETSELECTIONFADE
:
1608 return SpiGetUserPref(UPM_SELECTIONFADE
, pvParam
, fl
);
1610 case SPI_SETSELECTIONFADE
:
1611 return SpiSetUserPref(UPM_SELECTIONFADE
, pvParam
, fl
);
1613 case SPI_GETTOOLTIPANIMATION
:
1614 return SpiGetUserPref(UPM_TOOLTIPANIMATION
, pvParam
, fl
);
1616 case SPI_SETTOOLTIPANIMATION
:
1617 return SpiSetUserPref(UPM_TOOLTIPANIMATION
, pvParam
, fl
);
1619 case SPI_GETTOOLTIPFADE
:
1620 return SpiGetUserPref(UPM_TOOLTIPFADE
, pvParam
, fl
);
1622 case SPI_SETTOOLTIPFADE
:
1623 return SpiSetUserPref(UPM_TOOLTIPFADE
, pvParam
, fl
);
1625 case SPI_GETCURSORSHADOW
:
1626 return SpiGetUserPref(UPM_CURSORSHADOW
, pvParam
, fl
);
1628 case SPI_SETCURSORSHADOW
:
1629 gspv
.bMouseCursorShadow
= PtrToUlong(pvParam
);
1630 return SpiSetUserPref(UPM_CURSORSHADOW
, pvParam
, fl
);
1632 case SPI_GETUIEFFECTS
:
1633 return SpiGetUserPref(UPM_UIEFFECTS
, pvParam
, fl
);
1635 case SPI_SETUIEFFECTS
:
1636 return SpiSetUserPref(UPM_UIEFFECTS
, pvParam
, fl
);
1638 case SPI_GETMOUSESONAR
:
1639 return SpiGetInt(pvParam
, &gspv
.bMouseSonar
, fl
);
1641 case SPI_SETMOUSESONAR
:
1642 return SpiSetBool(&gspv
.bMouseSonar
, uiParam
, KEY_MOUSE
, L
"", fl
);
1644 case SPI_GETMOUSECLICKLOCK
:
1645 return SpiGetUserPref(UPM_CLICKLOCK
, pvParam
, fl
);
1647 case SPI_SETMOUSECLICKLOCK
:
1648 gspv
.bMouseClickLock
= PtrToUlong(pvParam
);
1649 return SpiSetUserPref(UPM_CLICKLOCK
, pvParam
, fl
);
1651 case SPI_GETMOUSEVANISH
:
1652 return SpiGetInt(pvParam
, &gspv
.bMouseVanish
, fl
);
1654 case SPI_SETMOUSEVANISH
:
1655 return SpiSetBool(&gspv
.bMouseVanish
, uiParam
, KEY_MOUSE
, L
"", fl
);
1657 case SPI_GETFLATMENU
:
1658 return SpiGetUserPref(UPM_FLATMENU
, pvParam
, fl
);
1660 case SPI_SETFLATMENU
:
1661 return SpiSetUserPref(UPM_FLATMENU
, pvParam
, fl
);
1663 case SPI_GETDROPSHADOW
:
1664 return SpiGetUserPref(UPM_DROPSHADOW
, pvParam
, fl
);
1666 case SPI_SETDROPSHADOW
:
1667 return SpiSetUserPref(UPM_DROPSHADOW
, pvParam
, fl
);
1669 case SPI_GETBLOCKSENDINPUTRESETS
:
1670 return SpiGetInt(pvParam
, &gspv
.bBlockSendInputResets
, fl
);
1672 case SPI_SETBLOCKSENDINPUTRESETS
:
1673 return SpiSetBool(&gspv
.bBlockSendInputResets
, uiParam
, KEY_MOUSE
, L
"", fl
);
1675 #if(_WIN32_WINNT >= 0x0600)
1676 case SPI_GETDISABLEOVERLAPPEDCONTENT
:
1677 return SpiGetInt(pvParam
, &gspv
.bDisableOverlappedContent
, fl
);
1679 case SPI_SETDISABLEOVERLAPPEDCONTENT
:
1680 return SpiSetBool(&gspv
.bDisableOverlappedContent
, uiParam
, KEY_MOUSE
, L
"", fl
);
1682 case SPI_GETCLIENTAREAANIMATION
:
1683 return SpiGetInt(pvParam
, &gspv
.bClientAreaAnimation
, fl
);
1685 case SPI_SETCLIENTAREAANIMATION
:
1686 return SpiSetBool(&gspv
.bClientAreaAnimation
, uiParam
, KEY_MOUSE
, L
"", fl
);
1688 case SPI_GETCLEARTYPE
:
1689 return SpiGetInt(pvParam
, &gspv
.bClearType
, fl
);
1691 case SPI_SETCLEARTYPE
:
1692 return SpiSetBool(&gspv
.bClearType
, uiParam
, KEY_MOUSE
, L
"", fl
);
1694 case SPI_GETSPEECHRECOGNITION
:
1695 return SpiGetInt(pvParam
, &gspv
.bSpeechRecognition
, fl
);
1697 case SPI_SETSPEECHRECOGNITION
:
1698 return SpiSetBool(&gspv
.bSpeechRecognition
, uiParam
, KEY_MOUSE
, L
"", fl
);
1701 case SPI_GETFOREGROUNDLOCKTIMEOUT
:
1702 return SpiGetInt(pvParam
, &gspv
.dwForegroundLockTimeout
, fl
);
1704 case SPI_SETFOREGROUNDLOCKTIMEOUT
:
1705 return SpiSetInt(&gspv
.dwForegroundLockTimeout
, uiParam
, KEY_MOUSE
, L
"", fl
);
1707 case SPI_GETACTIVEWNDTRKTIMEOUT
:
1708 return SpiGetInt(pvParam
, &gspv
.dwActiveTrackingTimeout
, fl
);
1710 case SPI_SETACTIVEWNDTRKTIMEOUT
:
1711 return SpiSetInt(&gspv
.dwActiveTrackingTimeout
, uiParam
, KEY_MOUSE
, L
"", fl
);
1713 case SPI_GETFOREGROUNDFLASHCOUNT
:
1714 return SpiGetInt(pvParam
, &gspv
.dwForegroundFlashCount
, fl
);
1716 case SPI_SETFOREGROUNDFLASHCOUNT
:
1717 return SpiSetInt(&gspv
.dwForegroundFlashCount
, uiParam
, KEY_MOUSE
, L
"", fl
);
1719 case SPI_GETCARETWIDTH
:
1720 return SpiGetInt(pvParam
, &gspv
.dwCaretWidth
, fl
);
1722 case SPI_SETCARETWIDTH
:
1723 return SpiSetInt(&gspv
.dwCaretWidth
, uiParam
, KEY_MOUSE
, L
"", fl
);
1725 case SPI_GETMOUSECLICKLOCKTIME
:
1726 return SpiGetInt(pvParam
, &gspv
.dwMouseClickLockTime
, fl
);
1728 case SPI_SETMOUSECLICKLOCKTIME
:
1729 return SpiSetDWord(&gspv
.dwMouseClickLockTime
, uiParam
, KEY_DESKTOP
, VAL_CLICKLOCKTIME
, fl
);
1731 case SPI_GETFONTSMOOTHINGTYPE
:
1732 return SpiGetInt(pvParam
, &gspv
.uiFontSmoothingType
, fl
);
1734 case SPI_SETFONTSMOOTHINGTYPE
:
1735 return SpiSetDWord(&gspv
.uiFontSmoothingType
, PtrToUlong(pvParam
), KEY_DESKTOP
, VAL_FONTSMOOTHINGTYPE
, fl
);
1737 case SPI_GETFONTSMOOTHINGCONTRAST
:
1738 return SpiGetInt(pvParam
, &gspv
.uiFontSmoothingContrast
, fl
);
1740 case SPI_SETFONTSMOOTHINGCONTRAST
:
1741 return SpiSetDWord(&gspv
.uiFontSmoothingContrast
, PtrToUlong(pvParam
), KEY_DESKTOP
, VAL_FONTSMOOTHINGCONTRAST
, fl
);
1743 case SPI_GETFOCUSBORDERWIDTH
:
1744 return SpiGetInt(pvParam
, &gspv
.uiFocusBorderWidth
, fl
);
1746 case SPI_SETFOCUSBORDERWIDTH
:
1747 return SpiSetInt(&gspv
.uiFocusBorderWidth
, uiParam
, KEY_MOUSE
, L
"", fl
);
1749 case SPI_GETFOCUSBORDERHEIGHT
:
1750 return SpiGetInt(pvParam
, &gspv
.uiFocusBorderHeight
, fl
);
1752 case SPI_SETFOCUSBORDERHEIGHT
:
1753 return SpiSetInt(&gspv
.uiFocusBorderHeight
, uiParam
, KEY_MOUSE
, L
"", fl
);
1755 case SPI_GETFONTSMOOTHINGORIENTATION
:
1756 return SpiGetInt(pvParam
, &gspv
.uiFontSmoothingOrientation
, fl
);
1758 case SPI_SETFONTSMOOTHINGORIENTATION
:
1759 return SpiSetDWord(&gspv
.uiFontSmoothingOrientation
, PtrToUlong(pvParam
), KEY_DESKTOP
, VAL_FONTSMOOTHINGORIENTATION
, fl
);
1761 /* The following are undocumented, but valid SPI values */
1786 ERR("Undocumented SPI value %x is unimplemented\n", uiAction
);
1790 ERR("Invalid SPI value: %u\n", uiAction
);
1791 EngSetLastError(ERROR_INVALID_PARAMETER
);
1799 SpiGetSetProbeBuffer(UINT uiAction
, UINT uiParam
, PVOID pvParam
)
1801 BOOL bToUser
= TRUE
;
1808 case SPI_GETKEYBOARDSPEED
:
1809 case SPI_GETSCREENSAVETIMEOUT
:
1810 case SPI_GETSCREENSAVEACTIVE
:
1811 case SPI_GETGRIDGRANULARITY
:
1812 case SPI_GETKEYBOARDDELAY
:
1813 case SPI_GETICONTITLEWRAP
:
1814 case SPI_GETMENUDROPALIGNMENT
:
1815 case SPI_GETFASTTASKSWITCH
:
1816 case SPI_GETDRAGFULLWINDOWS
:
1817 case SPI_GETSHOWSOUNDS
:
1818 case SPI_GETKEYBOARDPREF
:
1819 case SPI_GETSCREENREADER
:
1820 case SPI_GETFONTSMOOTHING
:
1821 case SPI_GETLOWPOWERTIMEOUT
:
1822 case SPI_GETPOWEROFFTIMEOUT
:
1823 case SPI_GETLOWPOWERACTIVE
:
1824 case SPI_GETPOWEROFFACTIVE
:
1825 case SPI_GETMOUSETRAILS
:
1826 case SPI_GETSNAPTODEFBUTTON
:
1827 case SPI_GETMOUSEHOVERWIDTH
:
1828 case SPI_GETMOUSEHOVERHEIGHT
:
1829 case SPI_GETMOUSEHOVERTIME
:
1830 case SPI_GETWHEELSCROLLLINES
:
1831 case SPI_GETMENUSHOWDELAY
:
1832 #if (_WIN32_WINNT >= 0x0600)
1833 case SPI_GETWHEELSCROLLCHARS
:
1835 case SPI_GETSHOWIMEUI
:
1836 case SPI_GETMOUSESPEED
:
1837 case SPI_GETSCREENSAVERRUNNING
:
1838 #if(WINVER >= 0x0600)
1839 case SPI_GETSCREENSAVESECURE
:
1841 case SPI_GETACTIVEWINDOWTRACKING
:
1842 case SPI_GETMENUANIMATION
:
1843 case SPI_GETCOMBOBOXANIMATION
:
1844 case SPI_GETLISTBOXSMOOTHSCROLLING
:
1845 case SPI_GETGRADIENTCAPTIONS
:
1846 case SPI_GETKEYBOARDCUES
:
1847 case SPI_GETACTIVEWNDTRKZORDER
:
1848 case SPI_GETHOTTRACKING
:
1849 case SPI_GETMENUFADE
:
1850 case SPI_GETSELECTIONFADE
:
1851 case SPI_GETTOOLTIPANIMATION
:
1852 case SPI_GETTOOLTIPFADE
:
1853 case SPI_GETCURSORSHADOW
:
1854 case SPI_GETUIEFFECTS
:
1855 case SPI_GETMOUSESONAR
:
1856 case SPI_GETMOUSECLICKLOCK
:
1857 case SPI_GETMOUSEVANISH
:
1858 case SPI_GETFLATMENU
:
1859 case SPI_GETDROPSHADOW
:
1860 case SPI_GETBLOCKSENDINPUTRESETS
:
1861 #if(_WIN32_WINNT >= 0x0600)
1862 case SPI_GETDISABLEOVERLAPPEDCONTENT
:
1863 case SPI_GETCLIENTAREAANIMATION
:
1864 case SPI_GETCLEARTYPE
:
1865 case SPI_GETSPEECHRECOGNITION
:
1867 case SPI_GETFOREGROUNDLOCKTIMEOUT
:
1868 case SPI_GETACTIVEWNDTRKTIMEOUT
:
1869 case SPI_GETFOREGROUNDFLASHCOUNT
:
1870 case SPI_GETCARETWIDTH
:
1871 case SPI_GETMOUSECLICKLOCKTIME
:
1872 case SPI_GETFONTSMOOTHINGTYPE
:
1873 case SPI_GETFONTSMOOTHINGCONTRAST
:
1874 case SPI_GETFOCUSBORDERWIDTH
:
1875 case SPI_GETFOCUSBORDERHEIGHT
:
1876 case SPI_GETFONTSMOOTHINGORIENTATION
:
1877 cbSize
= sizeof(INT
);
1880 case SPI_ICONHORIZONTALSPACING
:
1881 case SPI_ICONVERTICALSPACING
:
1882 if (pvParam
) cbSize
= sizeof(INT
);
1886 cbSize
= 3 * sizeof(INT
);
1889 case SPI_GETDESKWALLPAPER
:
1890 cbSize
= min(uiParam
, gspv
.ustrWallpaper
.Length
+ 1UL);
1893 case SPI_GETICONTITLELOGFONT
:
1894 cbSize
= sizeof(LOGFONTW
);
1897 case SPI_GETNONCLIENTMETRICS
:
1898 cbSize
= sizeof(NONCLIENTMETRICSW
);
1901 case SPI_GETMINIMIZEDMETRICS
:
1902 cbSize
= sizeof(MINIMIZEDMETRICS
);
1905 case SPI_GETICONMETRICS
:
1906 cbSize
= sizeof(ICONMETRICSW
);
1909 case SPI_GETWORKAREA
:
1910 cbSize
= sizeof(RECTL
);
1913 case SPI_GETFILTERKEYS
:
1914 cbSize
= sizeof(FILTERKEYS
);
1917 case SPI_GETTOGGLEKEYS
:
1918 cbSize
= sizeof(TOGGLEKEYS
);
1921 case SPI_GETMOUSEKEYS
:
1922 cbSize
= sizeof(MOUSEKEYS
);
1925 case SPI_GETSTICKYKEYS
:
1926 cbSize
= sizeof(STICKYKEYS
);
1929 case SPI_GETACCESSTIMEOUT
:
1930 cbSize
= sizeof(ACCESSTIMEOUT
);
1933 case SPI_GETSERIALKEYS
:
1934 cbSize
= sizeof(SERIALKEYS
);
1937 case SPI_GETSOUNDSENTRY
:
1938 cbSize
= sizeof(SOUNDSENTRYW
);
1941 case SPI_GETHIGHCONTRAST
:
1942 cbSize
= sizeof(HIGHCONTRASTW
);
1945 case SPI_GETANIMATION
:
1946 cbSize
= sizeof(ANIMATIONINFO
);
1949 case SPI_GETDEFAULTINPUTLANG
:
1950 cbSize
= sizeof(HKL
);
1953 #if(WINVER >= 0x0600)
1954 case SPI_GETAUDIODESCRIPTION
:
1955 cbSize
= sizeof(AUDIODESCRIPTION
);
1960 cbSize
= 3 * sizeof(INT
);
1964 case SPI_SETICONTITLELOGFONT
:
1965 cbSize
= sizeof(LOGFONTW
);
1969 case SPI_SETNONCLIENTMETRICS
:
1970 cbSize
= sizeof(NONCLIENTMETRICSW
);
1974 case SPI_SETMINIMIZEDMETRICS
:
1975 cbSize
= sizeof(MINIMIZEDMETRICS
);
1979 case SPI_SETICONMETRICS
:
1980 cbSize
= sizeof(ICONMETRICSW
);
1984 case SPI_SETWORKAREA
:
1985 cbSize
= sizeof(RECTL
);
1989 case SPI_SETFILTERKEYS
:
1990 cbSize
= sizeof(FILTERKEYS
);
1994 case SPI_SETTOGGLEKEYS
:
1995 cbSize
= sizeof(TOGGLEKEYS
);
1999 case SPI_SETMOUSEKEYS
:
2000 cbSize
= sizeof(MOUSEKEYS
);
2004 case SPI_SETSTICKYKEYS
:
2005 cbSize
= sizeof(STICKYKEYS
);
2009 case SPI_SETACCESSTIMEOUT
:
2010 cbSize
= sizeof(ACCESSTIMEOUT
);
2014 case SPI_SETSERIALKEYS
:
2015 cbSize
= sizeof(SERIALKEYS
);
2019 case SPI_SETSOUNDSENTRY
:
2020 cbSize
= sizeof(SOUNDSENTRYW
);
2024 case SPI_SETHIGHCONTRAST
:
2025 cbSize
= sizeof(HIGHCONTRASTW
);
2029 case SPI_SETANIMATION
:
2030 cbSize
= sizeof(ANIMATIONINFO
);
2034 case SPI_SETDEFAULTINPUTLANG
:
2035 cbSize
= sizeof(HKL
);
2039 case SPI_SETMOUSESPEED
:
2040 cbSize
= sizeof(INT
);
2051 ProbeForWrite(pvParam
, cbSize
, sizeof(UCHAR
));
2055 ProbeForRead(pvParam
, cbSize
, sizeof(UCHAR
));
2058 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
2060 _SEH2_YIELD(return FALSE
);
2070 UserSystemParametersInfo(
2077 PPROCESSINFO ppi
= PsGetCurrentProcessWin32Process();
2081 if (!gbSpiInitialized
)
2083 KeRosDumpStackFrames(NULL
, 20);
2088 /* Get a pointer to the current Windowstation */
2089 if (!ppi
->prpwinsta
)
2091 ERR("UserSystemParametersInfo called without active window station.\n");
2096 if ((fWinIni
& SPIF_PROTECT
) && !SpiGetSetProbeBuffer(uiAction
, uiParam
, pvParam
))
2098 EngSetLastError(ERROR_NOACCESS
);
2102 /* Do the actual operation */
2103 ulResult
= SpiGetSet(uiAction
, uiParam
, pvParam
, fWinIni
);
2105 /* Did we change something? */
2110 /* Update system metrics */
2113 /* Send notification to toplevel windows, if requested */
2114 if (fWinIni
& SPIF_SENDCHANGE
)
2116 /* Send WM_SETTINGCHANGE to all toplevel windows */
2117 co_IntSendMessageTimeout(HWND_BROADCAST
,
2133 NtUserSystemParametersInfo(
2141 TRACE("Enter NtUserSystemParametersInfo(%u)\n", uiAction
);
2142 UserEnterExclusive();
2144 // FIXME: Get rid of the flags and only use this from um. kernel can access data directly.
2145 /* Set UM memory protection flag */
2146 fWinIni
|= SPIF_PROTECT
;
2148 /* Call internal function */
2149 bResult
= UserSystemParametersInfo(uiAction
, uiParam
, pvParam
, fWinIni
);
2151 TRACE("Leave NtUserSystemParametersInfo, returning %d\n", bResult
);