locked
Problems with SystemParametersInfo RRS feed

  • Question

  • I have just been upgrading our application from using VC 2003 to the 2008 edition (VC 9.0). The final sticking point is that when I use:

    NONCLIENTMETRICS ncm;

    ncm.cbSize=sizeof(NONCLIENTMETRICS);
    ok=SystemParametersInfo(SPI_GETNONCLIENTMETRICS,sizeof(NONCLIENTMETRICS),&ncm,0);       


    it returns with ok=0 (ie an error has occurred) and the diagnostic from GetLastError is 1400=Invalid Window Handle. None of the fields in ncm other than the size which I set up have been touched by the call.

    As this call does not refer to any windows and is looking for system wide (non window specific) values, I am at a loss what to do.
    This worked as written with the previous version of the compiler (2003) and the documentation shows no dependecy on version of libc etc.

    I am running ion the same machine and OS setup as the previous builds with the old compiler and libraries

    Any ideas?

    Cheers

    Jeremy
    Friday, April 10, 2009 3:41 PM

Answers

  • Your code snippet as posted works fine when I try it with VS2008.  Try it again in a small test program to make sure that this is not affected by the rest of your code.
    Hans Passant.
    Friday, April 10, 2009 5:22 PM

All replies

  • Your code snippet as posted works fine when I try it with VS2008.  Try it again in a small test program to make sure that this is not affected by the rest of your code.
    Hans Passant.
    Friday, April 10, 2009 5:22 PM
  • Probably moot, but worth mentioning.  Have you tried initializing ncm with something like:

    NONCLIENTMETRICS ncm = {0};

    The return from GetLastError() could be a red herring.  Have you tried calling SetLastError() before trying the call.

    Tom
    Friday, April 10, 2009 7:00 PM
  • It's normal, it's a Win32 FAQ for a long time (paddle)
    See Google Groups, Win32 api
    Monday, April 13, 2009 11:10 AM
  • These kind of posts are pretty useless (paddle).  At least post a link.
    Hans Passant.
    Monday, April 13, 2009 12:14 PM
  • Carly
    can you post a link for the relevant FAQ - I am not having much luck finding the topic through Google?

    Cheers

    Jeremy
    Monday, April 20, 2009 4:10 PM