- What's wrong with this call to SystemParametersInfo?
- Posted by Larry Lindstrom on May 22nd, 2008
Hi Folks:
Developing on XP home, VS 2008 Pro, C++ WIN32, no MFC.
The following call to SystemParametersInfo() returns
a zero, indicating an error. GetLastError() returns 0.
The contents of non_client_metrics are unchanged by the
call.
NONCLIENTMETRICS non_client_metrics;
BOOL system_parameter_return_val = FALSE;
DWORD error_code = 0;
memset(&non_client_metrics, 0x00, sizeof non_client_metrics);
non_client_metrics.cbSize = sizeof non_client_metrics;
system_parameter_return_val =
SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof non_client_metrics,
&non_client_metrics,
0);
if(!system_parameter_return_val)
{
error_code = GetLastError();
}
I've had this call in a piece of code for several years,
but today it stopped working. Did I screw it up somehow?
I added the memset() today for testing.
I inserted this same code fragment as the first executable
statements in another project's WinMain, and SystemParametersInfo()
fails there too.
I tried to run SystemParametersInfo() with SPI_GETSOUNDSENTRY,
against a SOUNDSENTRY record, and that worked. It returned a
value of 1 and a couple of the values in the record were altered.
Is this another stupid mistake?
What am I doing wrong?
Thanks
Larry
- Posted by Sylvain SF on May 23rd, 2008
Larry Lindstrom wrote on 23/05/2008 01:57:
it does work under XP Pro SP2 with VS2005; user32.dll
shall not depend on dev. env., but perhaps it depends
on system; what are your SP and theme (classic or XP)?
what is your version of user32.dll?
Sylvain.
- Posted by Christian ASTOR on May 23rd, 2008
Larry Lindstrom wrote:
Size of structure is wrong.
See iPaddedBorderWidth (WINVER)...
- Posted by Larry Lindstrom on May 23rd, 2008
Christian ASTOR wrote:
Thanks Sylvain and Christian:
I now test for the compile time constant:
if(_WIN32_WINNT >= 0x0600)
{
non_client_metrics.cbSize -= sizeof (int);
}
It's odd, I'm sure this was working earlier today.
Larry
- Corrections to my SystemParametersInfo - it was incomplete (Development Resources) by n.keenan@ieee.org
- SystemParametersInfo(SPI_GETKEYBOARDDELAY will not cooperate (Development Resources) by n.keenan@ieee.org
- SystemParametersInfo API Call (Development Resources) by villeballer@hotmail.com
- Q: SystemParametersInfo? (Development Resources) by Jakob Bieling
- SystemParametersInfo / SPI_GETSCREENSAVEACTIVE (Development Resources) by Kaz

