INT Test_SPI_SETACCESSTIMEOUT(PTESTINFO pti) { ACCESSTIMEOUT atoOrig, atoTmp; /* Get original values */ atoOrig.cbSize = sizeof(ACCESSTIMEOUT); ASSERT(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoOrig, 0) == 1); atoTmp.cbSize = sizeof(ACCESSTIMEOUT) - 1; TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT) + 1; TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoTmp, 0) == 1); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 1, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, -1, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, sizeof(ACCESSTIMEOUT), &atoTmp, 0) == 1); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, sizeof(ACCESSTIMEOUT)-1, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, sizeof(ACCESSTIMEOUT)+1, &atoTmp, 0) == 0); /* Restore original values */ ASSERT(NtUserSystemParametersInfo(SPI_SETACCESSTIMEOUT, sizeof(atoOrig), &atoOrig, 0) == 1); return APISTATUS_NORMAL; }
void Test_SPI_SETACCESSTIMEOUT(void) { ACCESSTIMEOUT atoOrig, atoTmp; /* Get original values */ atoOrig.cbSize = sizeof(ACCESSTIMEOUT); ASSERT(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoOrig, 0) == 1); atoTmp.cbSize = sizeof(ACCESSTIMEOUT) - 1; TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT) + 1; TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &atoTmp, 0) == 1); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 1, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, -1, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, sizeof(ACCESSTIMEOUT), &atoTmp, 0) == 1); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, sizeof(ACCESSTIMEOUT)-1, &atoTmp, 0) == 0); atoTmp.cbSize = sizeof(ACCESSTIMEOUT); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, sizeof(ACCESSTIMEOUT)+1, &atoTmp, 0) == 0); /* Restore original values */ ASSERT(NtUserSystemParametersInfo(SPI_SETACCESSTIMEOUT, sizeof(atoOrig), &atoOrig, 0) == 1); }
void Test_SPI_SETFASTTASKSWITCH(void) { char buf[10]; TEST(NtUserSystemParametersInfo(SPI_SETFASTTASKSWITCH, 0, 0, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_SETFASTTASKSWITCH, 0, buf, 0) == 1); }
INT Test_SPI_SETFASTTASKSWITCH(PTESTINFO pti) { char buf[10]; TEST(NtUserSystemParametersInfo(SPI_SETFASTTASKSWITCH, 0, 0, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_SETFASTTASKSWITCH, 0, buf, 0) == 1); return APISTATUS_NORMAL; }
INT Test_UserPref(PTESTINFO pti, UINT uiGet, UINT uiSet, DWORD dwPrefMask) { BOOL bOrig, bTemp = 0; DWORD dwUserPref, dwUserPrefOrg; DWORD cbSize; /* Get original values */ NtUserSystemParametersInfo(uiGet, 0, &bOrig, 0); cbSize = sizeof(dwUserPrefOrg); QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPrefOrg, &cbSize, NULL); /* Value 0 */ NtUserSystemParametersInfo(uiSet, 0, NULL, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(uiGet, 0, &bTemp, 0); TEST(bTemp == 0); cbSize = sizeof(dwUserPref); TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPref, &cbSize, NULL) == ERROR_SUCCESS); TEST((dwUserPref & dwPrefMask) == 0); TEST((dwUserPref & (~dwPrefMask)) == (dwUserPrefOrg & (~dwPrefMask))); /* Value 1 without Registry */ NtUserSystemParametersInfo(uiSet, 0, (PVOID)1, 0); NtUserSystemParametersInfo(uiGet, 0, &bTemp, 0); TEST(bTemp == 1); cbSize = sizeof(dwUserPref); TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPref, &cbSize, NULL) == ERROR_SUCCESS); TEST((dwUserPref & dwPrefMask) == 0); TEST((dwUserPref & (~dwPrefMask)) == (dwUserPrefOrg & (~dwPrefMask))); /* Value 2 without Registry */ NtUserSystemParametersInfo(uiSet, 0, (PVOID)2, 0); NtUserSystemParametersInfo(uiGet, 0, &bTemp, 0); TEST(bTemp == 1); cbSize = sizeof(dwUserPref); TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPref, &cbSize, NULL) == ERROR_SUCCESS); TEST((dwUserPref & dwPrefMask) == 0); TEST((dwUserPref & (~dwPrefMask)) == (dwUserPrefOrg & (~dwPrefMask))); /* Value 1 with Registry */ NtUserSystemParametersInfo(uiSet, 0, (PVOID)1, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(uiGet, 0, &bTemp, 0); TEST(bTemp == 1); cbSize = sizeof(dwUserPref); TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPref, &cbSize, NULL) == ERROR_SUCCESS); TEST((dwUserPref & dwPrefMask) == dwPrefMask); TEST((dwUserPref & (~dwPrefMask)) == (dwUserPrefOrg & (~dwPrefMask))); /* Restore original value */ NtUserSystemParametersInfo(uiSet, 0, (PVOID)bOrig, SPIF_UPDATEINIFILE); return APISTATUS_NORMAL; }
void Test_SPI_SETMOUSE(PTESTINFO pti) { INT aiOrig[3], aiTemp[3]; /* Get original value */ NtUserSystemParametersInfo(SPI_GETMOUSE, 0, aiOrig, 0); /* Test uiParam value */ TEST(NtUserSystemParametersInfo(SPI_GETMOUSE, 0, aiTemp, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETMOUSE, 1, aiTemp, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETMOUSE, -1, aiTemp, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETMOUSE, 0xdeadbeef, aiTemp, 0) == 1); /* Set modified values */ aiTemp[0] = aiOrig[0] + 1; aiTemp[1] = aiOrig[1] - 1; aiTemp[2] = aiOrig[2] + 2; NtUserSystemParametersInfo(SPI_SETMOUSE, 2, aiTemp, SPIF_UPDATEINIFILE); aiTemp[0] = aiTemp[1] = aiTemp[2] = 0; /* Get new values */ NtUserSystemParametersInfo(SPI_GETMOUSE, 0, aiTemp, 0); /* Test modified values */ TEST(aiTemp[0] == aiOrig[0] + 1); TEST(aiTemp[1] == aiOrig[1] - 1); TEST(aiTemp[2] == aiOrig[2] + 2); // FIXME: Test registry values /* Restore original value */ NtUserSystemParametersInfo(SPI_SETMOUSE, 0, aiOrig, SPIF_UPDATEINIFILE); }
void Test_SPI_SETBORDER(PTESTINFO pti) { INT iOrig, iTemp = 0; /* Get original value */ NtUserSystemParametersInfo(SPI_GETBORDER, 0, &iOrig, 0); /* Value 0 */ NtUserSystemParametersInfo(SPI_SETBORDER, 0, NULL, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(SPI_GETBORDER, 0, &iTemp, 0); TEST(iTemp == 1); TEST(GetSystemMetrics(SM_CXBORDER) == 1); /* Value 1 */ NtUserSystemParametersInfo(SPI_SETBORDER, 1, NULL, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(SPI_GETBORDER, 0, &iTemp, 0); TEST(iTemp == 1); // Test_MetricKey(pti, VAL_BORDER, 1); /* Value 2 */ NtUserSystemParametersInfo(SPI_SETBORDER, 2, NULL, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(SPI_GETBORDER, 0, &iTemp, 0); TEST(iTemp == 2); TEST(GetSystemMetrics(SM_CXBORDER) == 1); /* Restore original value */ NtUserSystemParametersInfo(SPI_SETBORDER, iOrig, NULL, SPIF_UPDATEINIFILE); }
INT Test_SPI_SETMOUSEBUTTONSWAP(PTESTINFO pti) { BOOL bOrig, bTemp = 0; WCHAR szReg[10]; DWORD cbSize; /* Get original value */ bOrig = GetSystemMetrics(SM_SWAPBUTTON); /* Value 0 */ NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 0, NULL, SPIF_UPDATEINIFILE); bTemp = GetSystemMetrics(SM_SWAPBUTTON); TEST(bTemp == 0); cbSize = sizeof(szReg); TEST(QueryUserRegValueW(KEY_MOUSE, VAL_SWAP, &szReg, &cbSize, NULL) == ERROR_SUCCESS); TEST(_wcsicmp(szReg, L"0") == 0); /* Value 1 */ NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 1, NULL, SPIF_UPDATEINIFILE); bTemp = GetSystemMetrics(SM_SWAPBUTTON); TEST(bTemp == 1); cbSize = sizeof(szReg); TEST(QueryUserRegValueW(KEY_MOUSE, VAL_SWAP, &szReg, &cbSize, NULL) == ERROR_SUCCESS); TEST(_wcsicmp(szReg, L"1") == 0); /* Value 2 */ NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 2, NULL, SPIF_UPDATEINIFILE); bTemp = GetSystemMetrics(SM_SWAPBUTTON); TEST(bTemp == 1); cbSize = sizeof(szReg); TEST(QueryUserRegValueW(KEY_MOUSE, VAL_SWAP, &szReg, &cbSize, NULL) == ERROR_SUCCESS); TEST(_wcsicmp(szReg, L"2") == 0); /* Value -1 */ NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, -1, NULL, SPIF_UPDATEINIFILE); bTemp = GetSystemMetrics(SM_SWAPBUTTON); TEST(bTemp == 1); cbSize = sizeof(szReg); TEST(QueryUserRegValueW(KEY_MOUSE, VAL_SWAP, &szReg, &cbSize, NULL) == ERROR_SUCCESS); TEST(_wcsicmp(szReg, L"-1") == 0); /* Restore original value */ NtUserSystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, bOrig, 0, SPIF_UPDATEINIFILE); return APISTATUS_NORMAL; }
/* * @implemented */ BOOL WINAPI SetDoubleClickTime(UINT uInterval) { return (BOOL)NtUserSystemParametersInfo(SPI_SETDOUBLECLICKTIME, uInterval, NULL, 0); }
BOOL WINAPI RealSystemParametersInfoW(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni) { switch(uiAction) { case SPI_SETDESKWALLPAPER: { UNICODE_STRING ustrWallpaper; RtlInitUnicodeString(&ustrWallpaper, pvParam); return NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, uiParam, &ustrWallpaper, fWinIni); } } return NtUserSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni); }
INT Test_SPI_SETMENUANIMATION(PTESTINFO pti) { BOOL bOrig, bTemp = 0; DWORD dwUserPrefMask; DWORD cbSize; /* Get original values */ NtUserSystemParametersInfo(SPI_GETMENUANIMATION, 0, &bOrig, 0); /* Value 0 */ NtUserSystemParametersInfo(SPI_SETMENUANIMATION, 0, NULL, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(SPI_GETMENUANIMATION, 0, &bTemp, 0); TEST(bTemp == 0); cbSize = sizeof(dwUserPrefMask); TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPrefMask, &cbSize, NULL) == ERROR_SUCCESS); TEST((dwUserPrefMask & UPM_MENUANIMATION) == 0); /* Value 1 */ NtUserSystemParametersInfo(SPI_SETMENUANIMATION, 0, (PVOID)1, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(SPI_GETMENUANIMATION, 0, &bTemp, 0); TEST(bTemp == 1); cbSize = sizeof(dwUserPrefMask); TEST(QueryUserRegValueW(KEY_DESKTOP, VAL_PREFMASK, &dwUserPrefMask, &cbSize, NULL) == ERROR_SUCCESS); TEST((dwUserPrefMask & UPM_MENUANIMATION) != 0); /* Restore original values */ NtUserSystemParametersInfo(SPI_SETMENUANIMATION, 0, (PVOID)bOrig, SPIF_UPDATEINIFILE); return APISTATUS_NORMAL; }
INT Test_SPI_SETICONTITLELOGFONT(PTESTINFO pti) { LOGFONTW lfOrig; struct { LOGFONTW lf; DWORD dwRedzone; } buf; /* Get original value */ ASSERT(NtUserSystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfOrig), &lfOrig, 0)); /* Test uiParam == 0 */ memset(&buf, 0, sizeof(buf)); buf.lf.lfFaceName[LF_FACESIZE-1] = 33; buf.dwRedzone = 0xdeadbeef; TEST(NtUserSystemParametersInfo(SPI_GETICONTITLELOGFONT, 0, &buf.lf, 0) == 1); TEST(buf.lf.lfHeight != 0); TEST(buf.lf.lfWeight != 0); TEST(buf.lf.lfFaceName[0] != 0); TEST(buf.lf.lfFaceName[LF_FACESIZE-1] == 0); TEST(buf.dwRedzone == 0xdeadbeef); /* Test uiParam < sizeof(LOGFONTW) */ memset(&buf, 0, sizeof(buf)); buf.lf.lfFaceName[LF_FACESIZE-1] = 33; buf.dwRedzone = 0xdeadbeef; TEST(NtUserSystemParametersInfo(SPI_GETICONTITLELOGFONT, 8, &buf.lf, 0) == 1); TEST(buf.lf.lfHeight != 0); TEST(buf.lf.lfWeight != 0); TEST(buf.lf.lfFaceName[0] != 0); TEST(buf.lf.lfFaceName[LF_FACESIZE-1] == 0); TEST(buf.dwRedzone == 0xdeadbeef); /* Test uiParam < 0 */ TEST(NtUserSystemParametersInfo(SPI_GETICONTITLELOGFONT, -1, &buf.lf, 0) == 1); return APISTATUS_NORMAL; }
/* * @implemented */ BOOL WINAPI DrawFocusRect(HDC hdc, CONST RECT *rect) { HGDIOBJ OldObj; UINT cx, cy; NtUserSystemParametersInfo(SPI_GETFOCUSBORDERWIDTH, 0, &cx, 0); NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT, 0, &cy, 0); OldObj = SelectObject(hdc, gpsi->hbrGray); /* top */ PatBlt(hdc, rect->left, rect->top, rect->right - rect->left, cy, PATINVERT); /* bottom */ PatBlt(hdc, rect->left, rect->bottom - cy, rect->right - rect->left, cy, PATINVERT); /* left */ PatBlt(hdc, rect->left, rect->top + cy, cx, rect->bottom - rect->top - (2 * cy), PATINVERT); /* right */ PatBlt(hdc, rect->right - cx, rect->top + cy, cx, rect->bottom - rect->top - (2 * cy), PATINVERT); SelectObject(hdc, OldObj); return TRUE; }
void Test_NtUserSystemParametersInfo_fWinIni(PTESTINFO pti) { ACCESSTIMEOUT ato; // UINT uFocusBorderHeight; WCHAR Buffer[6]; DWORD cbSize; ato.cbSize = sizeof(ato); NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &ato, 0); ato.iTimeOutMSec++; NtUserSystemParametersInfo(SPI_SETACCESSTIMEOUT, 0, &ato, 0); ato.iTimeOutMSec--; // NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT, 0, &uFocusBorderHeight, 0); // NtUserSystemParametersInfo(SPI_SETFOCUSBORDERHEIGHT, 0, &uFocusBorderHeight, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(SPI_SETACCESSTIMEOUT, 0, &ato, 0); cbSize = 6; QueryUserRegValueW(L"Control Panel\\Accessibility\\TimeOut", L"TimeToWait", &Buffer, &cbSize, NULL); }
INT Test_NtUserUpdatePerUserSystemParameters(PTESTINFO pti) { BOOL bScrRd; TEST(NtUserUpdatePerUserSystemParameters(0, 0) == 0); TEST(NtUserUpdatePerUserSystemParameters(0, 1) == 0); TEST(NtUserUpdatePerUserSystemParameters(1, 0) == 0); TEST(NtUserUpdatePerUserSystemParameters(1, 1) == 0); TEST(NtUserUpdatePerUserSystemParameters(0, 2) == 0); TEST(NtUserUpdatePerUserSystemParameters(0, -1) == 0); // NtUserSystemParametersInfo(SPI_SETSCREENREADER, 1, 0, 0); NtUserSystemParametersInfo(SPI_GETSCREENREADER, 0, &bScrRd, 0); printf("bScrRd = %d\n", bScrRd); return APISTATUS_NORMAL; }
void Test_SPI_SETBEEP(PTESTINFO pti) { BOOL bOrig, bTemp = 0; WCHAR szReg[10]; DWORD cbSize; /* Get original value */ NtUserSystemParametersInfo(SPI_GETBEEP, 0, &bOrig, 0); /* Value 0 */ NtUserSystemParametersInfo(SPI_SETBEEP, 0, NULL, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(SPI_GETBEEP, 0, &bTemp, 0); TEST(bTemp == 0); cbSize = sizeof(szReg); TEST(QueryUserRegValueW(KEY_SOUND, VAL_BEEP, &szReg, &cbSize, NULL) == ERROR_SUCCESS); TEST(_wcsicmp(szReg, L"No") == 0); /* Value 1 */ NtUserSystemParametersInfo(SPI_SETBEEP, 1, NULL, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(SPI_GETBEEP, 0, &bTemp, 0); TEST(bTemp == 1); cbSize = sizeof(szReg); TEST(QueryUserRegValueW(KEY_SOUND, VAL_BEEP, &szReg, &cbSize, NULL) == ERROR_SUCCESS); TEST(_wcsicmp(szReg, L"Yes") == 0); /* Value 2 */ NtUserSystemParametersInfo(SPI_SETBEEP, 2, NULL, SPIF_UPDATEINIFILE); NtUserSystemParametersInfo(SPI_GETBEEP, 0, &bTemp, 0); TEST(bTemp == 1); cbSize = sizeof(szReg); TEST(QueryUserRegValueW(KEY_SOUND, VAL_BEEP, &szReg, &cbSize, NULL) == ERROR_SUCCESS); TEST(_wcsicmp(szReg, L"Yes") == 0); /* Restore original value */ NtUserSystemParametersInfo(SPI_SETBEEP, 0, &bOrig, SPIF_UPDATEINIFILE); }
void Test_SPI_SETDESKWALLPAPER(PTESTINFO pti) { UNICODE_STRING ustrOld, ustrNew; WCHAR szOld[MAX_PATH]; WCHAR szNew[MAX_PATH]; /* Get old Wallpaper */ TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szOld, 0) == 1); RtlInitUnicodeString(&ustrOld, szOld); /* Set no Wallpaper */ TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, L"", 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1); TEST(szNew[0] == 0); /* Set no Wallpaper 2 */ RtlInitUnicodeString(&ustrNew, L""); TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &ustrNew, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1); TEST(szNew[0] == 0); /* Reset Wallpaper */ TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, NULL, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1); TEST(wcscmp(szNew, szOld) == 0); /* Set new Wallpaper */ RtlInitUnicodeString(&ustrNew, L"test.bmp"); TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &ustrNew, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1); TEST(wcscmp(szNew, L"test.bmp") == 0); /* Get Wallpaper, too small buffer */ szNew[0] = 0; szNew[1] = 0; szNew[2] = 0; TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, 3, szNew, 0) == 1); TEST(szNew[0] != 0); TEST(szNew[1] != 0); TEST(szNew[2] != 0); /* Set invalid Wallpaper */ SetLastError(0xdeadbeef); RtlInitUnicodeString(&ustrNew, L"*#!!-&"); TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, 0, &ustrNew, 0) == 0); TEST(GetLastError() == ERROR_FILE_NOT_FOUND); TEST(NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, szNew, 0) == 1); TEST(wcscmp(szNew, L"*#!!-&") == 0); /* Restore old Wallpaper */ TEST(NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, MAX_PATH, &ustrOld, SPIF_UPDATEINIFILE) == 1); }
BOOL WINAPI RealSystemParametersInfoA(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni) { switch (uiAction) { case SPI_GETNONCLIENTMETRICS: { LPNONCLIENTMETRICSA pnclma = (LPNONCLIENTMETRICSA)pvParam; NONCLIENTMETRICSW nclmw; if(pnclma->cbSize != sizeof(NONCLIENTMETRICSA)) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } nclmw.cbSize = sizeof(NONCLIENTMETRICSW); if (!SystemParametersInfoW(uiAction, sizeof(NONCLIENTMETRICSW), &nclmw, fWinIni)) return FALSE; pnclma->iBorderWidth = nclmw.iBorderWidth; pnclma->iScrollWidth = nclmw.iScrollWidth; pnclma->iScrollHeight = nclmw.iScrollHeight; pnclma->iCaptionWidth = nclmw.iCaptionWidth; pnclma->iCaptionHeight = nclmw.iCaptionHeight; pnclma->iSmCaptionWidth = nclmw.iSmCaptionWidth; pnclma->iSmCaptionHeight = nclmw.iSmCaptionHeight; pnclma->iMenuWidth = nclmw.iMenuWidth; pnclma->iMenuHeight = nclmw.iMenuHeight; LogFontW2A(&(pnclma->lfCaptionFont), &(nclmw.lfCaptionFont)); LogFontW2A(&(pnclma->lfSmCaptionFont), &(nclmw.lfSmCaptionFont)); LogFontW2A(&(pnclma->lfMenuFont), &(nclmw.lfMenuFont)); LogFontW2A(&(pnclma->lfStatusFont), &(nclmw.lfStatusFont)); LogFontW2A(&(pnclma->lfMessageFont), &(nclmw.lfMessageFont)); return TRUE; } case SPI_SETNONCLIENTMETRICS: { LPNONCLIENTMETRICSA pnclma = (LPNONCLIENTMETRICSA)pvParam; NONCLIENTMETRICSW nclmw; if(pnclma->cbSize != sizeof(NONCLIENTMETRICSA)) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } nclmw.cbSize = sizeof(NONCLIENTMETRICSW); nclmw.iBorderWidth = pnclma->iBorderWidth; nclmw.iScrollWidth = pnclma->iScrollWidth; nclmw.iScrollHeight = pnclma->iScrollHeight; nclmw.iCaptionWidth = pnclma->iCaptionWidth; nclmw.iCaptionHeight = pnclma->iCaptionHeight; nclmw.iSmCaptionWidth = pnclma->iSmCaptionWidth; nclmw.iSmCaptionHeight = pnclma->iSmCaptionHeight; nclmw.iMenuWidth = pnclma->iMenuWidth; nclmw.iMenuHeight = pnclma->iMenuHeight; LogFontA2W(&(nclmw.lfCaptionFont), &(pnclma->lfCaptionFont)); LogFontA2W(&(nclmw.lfSmCaptionFont), &(pnclma->lfSmCaptionFont)); LogFontA2W(&(nclmw.lfMenuFont), &(pnclma->lfMenuFont)); LogFontA2W(&(nclmw.lfStatusFont), &(pnclma->lfStatusFont)); LogFontA2W(&(nclmw.lfMessageFont), &(pnclma->lfMessageFont)); return SystemParametersInfoW(uiAction, sizeof(NONCLIENTMETRICSW), &nclmw, fWinIni); } case SPI_GETICONMETRICS: { LPICONMETRICSA picma = (LPICONMETRICSA)pvParam; ICONMETRICSW icmw; if(picma->cbSize != sizeof(ICONMETRICSA)) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } icmw.cbSize = sizeof(ICONMETRICSW); if (!SystemParametersInfoW(uiAction, sizeof(ICONMETRICSW), &icmw, fWinIni)) return FALSE; picma->iHorzSpacing = icmw.iHorzSpacing; picma->iVertSpacing = icmw.iVertSpacing; picma->iTitleWrap = icmw.iTitleWrap; LogFontW2A(&(picma->lfFont), &(icmw.lfFont)); return TRUE; } case SPI_SETICONMETRICS: { LPICONMETRICSA picma = (LPICONMETRICSA)pvParam; ICONMETRICSW icmw; if(picma->cbSize != sizeof(ICONMETRICSA)) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; } icmw.cbSize = sizeof(ICONMETRICSW); icmw.iHorzSpacing = picma->iHorzSpacing; icmw.iVertSpacing = picma->iVertSpacing; icmw.iTitleWrap = picma->iTitleWrap; LogFontA2W(&(icmw.lfFont), &(picma->lfFont)); return SystemParametersInfoW(uiAction, sizeof(ICONMETRICSW), &icmw, fWinIni); } case SPI_GETICONTITLELOGFONT: { LOGFONTW lfw; if (!SystemParametersInfoW(uiAction, 0, &lfw, fWinIni)) return FALSE; LogFontW2A(pvParam, &lfw); return TRUE; } case SPI_SETICONTITLELOGFONT: { LPLOGFONTA plfa = (LPLOGFONTA)pvParam; LOGFONTW lfw; LogFontA2W(&lfw,plfa); return SystemParametersInfoW(uiAction, 0, &lfw, fWinIni); } case SPI_GETDESKWALLPAPER: { BOOL Ret; WCHAR awc[MAX_PATH]; UNICODE_STRING ustrWallpaper; ANSI_STRING astrWallpaper; Ret = NtUserSystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, awc, fWinIni); RtlInitUnicodeString(&ustrWallpaper, awc); RtlUnicodeStringToAnsiString(&astrWallpaper, &ustrWallpaper, TRUE); RtlCopyMemory(pvParam, astrWallpaper.Buffer, uiParam); RtlFreeAnsiString(&astrWallpaper); return Ret; } case SPI_SETDESKWALLPAPER: { UNICODE_STRING ustrWallpaper; BOOL Ret; if (pvParam) { if (!RtlCreateUnicodeStringFromAsciiz(&ustrWallpaper, pvParam)) { ERR("RtlCreateUnicodeStringFromAsciiz failed\n"); return FALSE; } pvParam = &ustrWallpaper; } Ret = NtUserSystemParametersInfo(SPI_SETDESKWALLPAPER, uiParam, pvParam, fWinIni); if (pvParam) RtlFreeUnicodeString(&ustrWallpaper); return Ret; } } return NtUserSystemParametersInfo(uiAction, uiParam, pvParam, fWinIni); }
INT Test_SPI_SETSTICKYKEYS(PTESTINFO pti) { STICKYKEYS skOrig, sk; /* Get original values */ skOrig.cbSize = sizeof(STICKYKEYS); ASSERT(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 0, &skOrig, 0) == 1); sk.cbSize = sizeof(STICKYKEYS)+1; TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 0, &sk, 0) == 0); sk.cbSize = sizeof(STICKYKEYS)-1; TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 0, &sk, 0) == 0); sk.cbSize = sizeof(STICKYKEYS); TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 1, &sk, 0) == 0); TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, -1, &sk, 0) == 0); TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, sk.cbSize, &sk, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, sk.cbSize-1, &sk, 0) == 0); TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, sk.cbSize+1, &sk, 0) == 0); sk = skOrig; sk.dwFlags = (skOrig.dwFlags ^ 1); TEST(NtUserSystemParametersInfo(SPI_SETSTICKYKEYS, sk.cbSize+1, &sk, 0) == 0); TEST(NtUserSystemParametersInfo(SPI_SETSTICKYKEYS, sk.cbSize-1, &sk, 0) == 0); TEST(NtUserSystemParametersInfo(SPI_SETSTICKYKEYS, sk.cbSize, &sk, 0) == 1); sk = skOrig; TEST(NtUserSystemParametersInfo(SPI_GETSTICKYKEYS, 0, &sk, 0) == 1); TEST(sk.dwFlags == (skOrig.dwFlags ^ 1)); /* Restore original values */ skOrig.cbSize = sizeof(STICKYKEYS); ASSERT(NtUserSystemParametersInfo(SPI_SETSTICKYKEYS, 0, &skOrig, 0) == 1); return APISTATUS_NORMAL; }
INT Test_SPI_SETWORKAREA(PTESTINFO pti) { RECT rcOrig, rc; /* Get the original value */ ASSERT(NtUserSystemParametersInfo(SPI_GETWORKAREA, 0, &rcOrig, 0) == 1); /* Change value */ rc = rcOrig; rc.left += 1; rc.top += 2; rc.right -= 3; rc.bottom -= 2; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 1, &rc, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, sizeof(RECT), &rc, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETWORKAREA, 1, &rc, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETWORKAREA, -1, &rc, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETWORKAREA, 0xdeadbeef, &rc, 0) == 1); TEST(NtUserSystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID)0xdeadbeef, 0) == 0); /* Test values */ rc = rcOrig; rc.left = -1; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0); rc = rcOrig; rc.top = -1; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0); rc = rcOrig; rc.top = 10; rc.bottom = 11; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1); rc = rcOrig; rc.top = 10; rc.bottom = 10; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0); rc = rcOrig; rc.top = 10; rc.bottom = 9; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0); rc = rcOrig; rc.left = 10; rc.right = 11; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1); rc = rcOrig; rc.left = 10; rc.right = 10; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0); rc = rcOrig; rc.left = 10; rc.right = 9; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0); rc = rcOrig; rc.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN); TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1); rc = rcOrig; rc.bottom = GetSystemMetrics(SM_CYVIRTUALSCREEN)+1; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0); rc = rcOrig; rc.right = GetSystemMetrics(SM_CXVIRTUALSCREEN); TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 1); rc = rcOrig; rc.right = GetSystemMetrics(SM_CXVIRTUALSCREEN)+1; TEST(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rc, 0) == 0); /* Restore original value */ ASSERT(NtUserSystemParametersInfo(SPI_SETWORKAREA, 0, &rcOrig, 0) == 1); return APISTATUS_NORMAL; }
void Test_NtUserSystemParametersInfo_Params(PTESTINFO pti) { // UINT uint; DWORD data[1000]; UINT i, uint; ACCESSTIMEOUT ato; /* Test normal */ SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT, 0, &uint, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); /* Test invalid SPI code */ SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(7, 0, &data, 0) == FALSE); TEST(GetLastError() == ERROR_INVALID_PARAMETER); /* Test wrong cbSize member */ ato.cbSize = 1; SetLastError(0xdeadbeef); TEST(NtUserSystemParametersInfo(SPI_GETACCESSTIMEOUT, 0, &ato, 0) == FALSE); TEST(GetLastError() == 0xdeadbeef); #if 0 /* Test undocumented, but valid SPI codes */ for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(0x1010, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] <= 1); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(0x1011, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); data[0] = 0; NtUserSystemParametersInfo(0x1010, 0, &data, 0); TEST(data[0] == 1); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(0x1028, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(0x1029, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(0x102A, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4139, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4140, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4141, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4142, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4143, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4144, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4145, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4146, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4147, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4148, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4149, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4150, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4151, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4152, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4153, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4154, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4155, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4156, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] != 0xdeadbeef); TEST(data[1] == 0xdeadbeef); for(i = 0; i < 1000; i++) data[i] = 0xbeefdead; SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(4157, 0, &data, 0) == TRUE); TEST(GetLastError() == ERROR_SUCCESS); TEST(data[0] == 0xbeefdead); TEST(data[1] == 0xbeefdead); #endif /* Test invalid pointer */ SetLastError(ERROR_SUCCESS); TEST(NtUserSystemParametersInfo(SPI_GETFOCUSBORDERHEIGHT, 0, (PVOID)0x80000000, 0) == FALSE); TEST(GetLastError() == ERROR_NOACCESS); for(i = 0; i < 1000; i++) data[i] = 0xdeadbeef; /* test wrong bools */ }