EnumDisplaySettings() always returns false
-
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
-
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
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
-
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
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
-
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
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
-
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
I have no loops for this functions. This function is called the same way I noted earlier after EnumDisplayDevices() only once. thanks
PKNT
-
I have no loops for this functions. This function is called the same way I noted earlier after EnumDisplayDevices() only once. thanks
PKNT
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
-
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
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
-
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
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
-
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
UAC on my system is turned off. So, I guess its not causing the problem as the first function runs fine. thanks
PKNT