Thread: finding monitor refresh rate

  1. #1
    eats only heads
    Guest

    finding monitor refresh rate

    I want to creat a program to detect the monitor refrest rate. First of is there any simple os independent way of doing this? If not then I think I would have to

    1. Determine OS

    2. Based on os determine where to look to find what monitor driver is being used.

    3. Find the diver and view what the refresh rate is.

    now what files should I look at to find these three things. I am using windows 98se so that would be a good OS to start with. Also I would prefer like a C based solution which doesn't involve to many libs because this is for another projects and I don't want to mess things up.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    This might work:

    Code:
    DEVMODE screen; 
    memset(&screen, 0, sizeof(DEVMODE));
      if(!EnumDisplaySettings(NULL, 0, &screen)){
      MessageBox(NULL, "Couldn't obtain refresh rate.", "Failure.", MB_OK);
    return 0;
    }
    char message[100];
    sprintf(message, "The current refresh rate is %i", screen.dmDisplayFrequency);
    MessageBox(NULL, message, "Refresh Rate:", MB_OK);
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Odd. It gave me "0". I even indexed through all of the graphics modes:

    Code:
    int index = 0;
    DEVMODE screen; 
    memset(&screen, 0, sizeof(DEVMODE));
    while(EnumDisplaySettings(NULL, index++, &screen)){
    char message[100];
    sprintf(message, "The current refresh rate is %i", screen.dmDisplayFrequency);
    MessageBox(NULL, message, "Refresh Rate:", MB_OK);
    memset(&screen, 0, sizeof(DEVMODE));
    }

    [edit]

    Here's what the docs say:

    "...A refresh rate value of 0 or 1 represents the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard..."

    In other words, that method is inadequate because you may often get the useless values of 0 or 1...

    Good luck.

    [/edit]
    Last edited by Sebastiani; 12-14-2002 at 04:16 PM.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Producing a "beeep!" as simply as possible
    By mutandis in forum C Programming
    Replies: 10
    Last Post: 12-13-2008, 01:30 AM
  2. Question About My Homework Pls Help Me İmmediately
    By jennyyyy in forum C Programming
    Replies: 27
    Last Post: 03-13-2008, 11:40 AM
  3. Changing Refresh Rate With ChangeDisplaySettings()
    By iSlak in forum Windows Programming
    Replies: 4
    Last Post: 09-27-2005, 12:33 AM
  4. the effects of textures on my frame rate
    By DavidP in forum Game Programming
    Replies: 37
    Last Post: 10-03-2003, 11:24 AM
  5. MFC :: Finding Child Window of a CWnd* Object?
    By SyntaxBubble in forum Windows Programming
    Replies: 2
    Last Post: 09-06-2003, 09:06 AM