Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. EnumDisplaySettings() always returns false

EnumDisplaySettings() always returns false

Scheduled Pinned Locked Moved C / C++ / MFC
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kiran Satish
    wrote on last edited by
    #1

    I am trying to get the resolution of all the monitors that are on connected to the system. Here is how I am trying to do 1) Read number of monitors in the system 2) For each monitor get the device info using EnumDisplayDevices(). 3) In step2, I am getting all the info including DeviceName 4) Using the DeviceName from above I am calling EnumDisplaySettings(), but this function is always returning false except when I use NULL for the first parameter where it gives me details of primary monitor. Any ideas why its returning false when using the DeviceName from step2. thanks

    PKNT

    _ K 2 Replies Last reply
    0
    • K Kiran Satish

      I am trying to get the resolution of all the monitors that are on connected to the system. Here is how I am trying to do 1) Read number of monitors in the system 2) For each monitor get the device info using EnumDisplayDevices(). 3) In step2, I am getting all the info including DeviceName 4) Using the DeviceName from above I am calling EnumDisplaySettings(), but this function is always returning false except when I use NULL for the first parameter where it gives me details of primary monitor. Any ideas why its returning false when using the DeviceName from step2. thanks

      PKNT

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      Quoting from MSDN: Graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to EnumDisplaySettings, as follows: Set iModeNum to zero for the first call, and increment iModeNum by one for each subsequent call. Continue calling the function until the return value is zero. When you call EnumDisplaySettings with iModeNum set to zero, the operating system initializes and caches information about the display device. When you call EnumDisplaySettings with iModeNum set to a nonzero value, the function returns the information that was cached the last time the function was called with iModeNum set to zero. Check if it helps

      You talk about Being HUMAN. I have it in my name AnsHUMAN

      K 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        Quoting from MSDN: Graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to EnumDisplaySettings, as follows: Set iModeNum to zero for the first call, and increment iModeNum by one for each subsequent call. Continue calling the function until the return value is zero. When you call EnumDisplaySettings with iModeNum set to zero, the operating system initializes and caches information about the display device. When you call EnumDisplaySettings with iModeNum set to a nonzero value, the function returns the information that was cached the last time the function was called with iModeNum set to zero. Check if it helps

        You talk about Being HUMAN. I have it in my name AnsHUMAN

        K Offline
        K Offline
        Kiran Satish
        wrote on last edited by
        #3

        Thanks for the info. But I already tried this with the same result.

        result = EnumDisplaySettings(lpdParams.DeviceName,0,&lpDMode);

        where lpdParams is DISPLAY_DEVICE variable that has been populated with data returned from

        EnumDisplayDevices(NULL, 1, &lpdParams, EDD_GET_DEVICE_INTERFACE_NAME);

        Not sure where I am doing wrong. thanks

        PKNT

        D 1 Reply Last reply
        0
        • K Kiran Satish

          Thanks for the info. But I already tried this with the same result.

          result = EnumDisplaySettings(lpdParams.DeviceName,0,&lpDMode);

          where lpdParams is DISPLAY_DEVICE variable that has been populated with data returned from

          EnumDisplayDevices(NULL, 1, &lpdParams, EDD_GET_DEVICE_INTERFACE_NAME);

          Not sure where I am doing wrong. thanks

          PKNT

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Do you have some sort of loop set up for this? Something like:

          int result = -1;

          for (int x = 0; result != 0; x++)
          result = EnumDisplaySettings(lpdParams.DeviceName, x, &lpDMode);

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          K 1 Reply Last reply
          0
          • D David Crow

            Do you have some sort of loop set up for this? Something like:

            int result = -1;

            for (int x = 0; result != 0; x++)
            result = EnumDisplaySettings(lpdParams.DeviceName, x, &lpDMode);

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

            K Offline
            K Offline
            Kiran Satish
            wrote on last edited by
            #5

            I have no loops for this functions. This function is called the same way I noted earlier after EnumDisplayDevices() only once. thanks

            PKNT

            D 1 Reply Last reply
            0
            • K Kiran Satish

              I have no loops for this functions. This function is called the same way I noted earlier after EnumDisplayDevices() only once. thanks

              PKNT

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Kiran Satish wrote:

              I have no loops for this functions.

              My bad. I just assumed when _AnsHUMAN_ suggested the same thing, that your "But I already tried this..." reply meant you were using a loop of some sort.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

              1 Reply Last reply
              0
              • K Kiran Satish

                I am trying to get the resolution of all the monitors that are on connected to the system. Here is how I am trying to do 1) Read number of monitors in the system 2) For each monitor get the device info using EnumDisplayDevices(). 3) In step2, I am getting all the info including DeviceName 4) Using the DeviceName from above I am calling EnumDisplaySettings(), but this function is always returning false except when I use NULL for the first parameter where it gives me details of primary monitor. Any ideas why its returning false when using the DeviceName from step2. thanks

                PKNT

                K Offline
                K Offline
                Kiran Satish
                wrote on last edited by
                #7

                I found out that this problem is only on Windows 7, the function ran fine on XP. Any ideas about this issue on win7?? thanks

                PKNT

                D 1 Reply Last reply
                0
                • K Kiran Satish

                  I found out that this problem is only on Windows 7, the function ran fine on XP. Any ideas about this issue on win7?? thanks

                  PKNT

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Kiran Satish wrote:

                  Any ideas about this issue on win7??

                  UAC, perhaps?

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                  K 1 Reply Last reply
                  0
                  • D David Crow

                    Kiran Satish wrote:

                    Any ideas about this issue on win7??

                    UAC, perhaps?

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                    K Offline
                    K Offline
                    Kiran Satish
                    wrote on last edited by
                    #9

                    UAC on my system is turned off. So, I guess its not causing the problem as the first function runs fine. thanks

                    PKNT

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups