Thread: SystemParametersInfo error

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    3

    SystemParametersInfo error

    Hi all,

    I am trying to port an application from VC++ 6.0 to Visual Studio 2008. The code is not written by me.

    When function SystemParametersInfo() is invocked it returns FALSE, but when I check the error with GetLastError(), return value is 0 (zero). Anyhow, the behaviour is like the function had failed.

    The same code works properly when compiled with VC++ 6.0

    What I am doing wrong?
    Thanks,
    ovi

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Quote Originally Posted by ovi View Post
    Hi all,

    I am trying to port an application from VC++ 6.0 to Visual Studio 2008. The code is not written by me.

    When function SystemParametersInfo() is invocked it returns FALSE, but when I check the error with GetLastError(), return value is 0 (zero). Anyhow, the behaviour is like the function had failed.

    The same code works properly when compiled with VC++ 6.0

    What I am doing wrong?
    Thanks,
    ovi
    There are various params to that function that are specific to the version of Windows. Post the code that returns FALSE

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    3
    Hi Fordy,

    Thanks for interest. Here is the piece of code with problems
    Code:
       int error =0;      //for debug
       TCHAR errmes[50];  //for debug
    
       NONCLIENTMETRICS ncm;
       ncm.cbSize = sizeof(NONCLIENTMETRICS);
    if(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0))
    	{
    		AfxMessageBox("SytemParametersInfo = OK"); //for debug
    
    	}
    	else
    	{
    	   error = GetLastError();
    	   sprintf(errmes,"SystemParametersInfo ERROR\nLast Error = %d",error); //for debug
     	   AfxMessageBox(errmes);
    	}
          memcpy(&m_Logfont, &(ncm.lfMessageFont), sizeof(LOGFONT));

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Try set the size of the struct to "sizeof(NONCLIENTMETRICS) - sizeof(ncm.iPaddedBorderWidth);"

    There's an addition to that struct (iPaddedBorderWidth) that seems to screw it up between Vista & XP

    More info here - NONCLIENTMETRICS Structure (Windows)

  5. #5
    Registered User
    Join Date
    Aug 2010
    Posts
    3
    Thanks for the hint. Unfortunatelly, it doesn't work. It behaves exactly the same.
    Btw, I am using Windows XP.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock problem
    By Wolf` in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2010, 04:55 PM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM