Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how can I query for graphics hardware capabilities/state under a Win32 environment?

Posted on 2004-10-26
8
Medium Priority
?
360 Views
Last Modified: 2011-09-20
Hi experts,

I'm programming a small OpenGL application on a Win32 window. I would like to automatically detect the graphics card that is installed on the system where the application is running, as well as its features (i.e. current resolution, current bit depth, current refresh rate,dual monitors?, if yes, which one is the primary, its resolution, refresh rate, maximum resolution, maximum refresh rate,...). So, basically, how can I query for graphics hardware capabilities?

At the moment, what I have is an structure that can hold the default resolution, default bit depth, default refresh rate, the name of the graphics card, the name of the vendor (e.g. NVIDIA), and the model of the graphics card. I do this by accesing a registry key, however, I think this is an "unelegant" way of doing it. I was thinking, maybe I could use some DirectX commands, I've heard that it is easier for obtaining hardware features.

Any piece of advice will be welcome, and since this is not an easy question (I've done a thourough search on the web, and have found nothing so far =( _  if you provide me with a very good answer, I'll double the points.
0
Comment
Question by:Trancos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
8 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 400 total points
ID: 12410437
There is not a unique method to retrieve all the information you want.

To enumerate all your monitors, use EnumDisplayMonitors() WinAPI function (http://msdn.microsoft.com/library/en-us/gdi/monitor_82yb.asp). It will require a callback function.

Every time the callback function is callled, you will receive a HMONITOR handle, use this handle to obtain monitor coordinates and devicename by using GetMonitorInfo (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/monitor_27e7.asp)

 
0
 
LVL 6

Assisted Solution

by:Svetlin_Panayotov
Svetlin_Panayotov earned 200 total points
ID: 12410549
For basic information about display depth/resolution etc. you can use EnumDisplayDevices and EnumDisplaySettings / EnumDisplaySettingsEx.
0
 
LVL 6

Expert Comment

by:Svetlin_Panayotov
ID: 12410565
Whoops.Sorry jamie - bad refresh again :(
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
LVL 1

Author Comment

by:Trancos
ID: 12525580
Thanks for your comments. I have tried your solution Svetlin but there is one major problem, I can't use the windows.h header file, so EnumDisplayDevices is not accessible. Is there anything similar to this function that works with stdafx? or about the EnumDisplayMonitors() winapi function, I don't quite well how dos the callback function "MonitorEnumProc" works? what am I suppose to put in there?

I'm increasing the points for this questions, as time is becoming a problem.

Cheers
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12532851
> I have tried your solution Svetlin but there is one major problem, I can't use the windows.h header file, so EnumDisplayDevices is not accessible

I am not sure what do you mean with that, but there is a trick to use those functions:

#include "stdafx.h"
// some other included headers here

// this macro is needed before calling multimonitor functions
#define COMPILE_MULTIMON_STUBS
#include "multimon.h"

-----

About how to use it:

// Somewhere into your application
HMONITOR monitor = NULL;
EnumDisplayMonitors(NULL, NULL, enumMonitors, (LPARAM)&monitor);

// Here is the callback function, it will be called as many times as monitor you have installed

BOOL CALLBACK enumMonitors(HMONITOR monitor, HDC dc, LPRECT rect, LPARAM param)
{
   static moncount = 0;
   MONITORINFOEX mi;

      mi.cbSize = sizeof(MONITORINFOEX);
      if (GetMonitorInfo(monitor, (LPMONITORINFO)&mi)) {
                        // Process some monitor information here and increment monitor counter
                        moncount++;
                }
      return TRUE;
}
0
 
LVL 1

Author Comment

by:Trancos
ID: 12535158
Thank you Jaime, I have tried your approach, but every time I try to compile the program the compiler displays:
 error C2065: 'HMONITOR' : undeclared identifier

I have included:
>#include "stdafx.h"
>// some other included headers here
>
>// this macro is needed before calling multimonitor functions
>#define COMPILE_MULTIMON_STUBS
>#include "multimon.h"

Nevertheless this doesn't help, I have moved the "multimon.h" file from its original folder on VC7/frameworkSDK to the program's folder, but this didn't help =(

By the way, what I meant on  my previous comment, is that since I'm using "stdafx.h", there are some precompiler headers that don't allow the solution to use the library <windows.h> on my program.

Any other suggestions will be very much appreciate it.
0
 
LVL 6

Expert Comment

by:Svetlin_Panayotov
ID: 12733402
I don't think that there's something wrong with the solutions I and jaime_olivares gave.Since Trancos is unable to use <windows.h> in the app - this will not work of course.So in this case - our comments are of no use.But maybe the question should be just marked as PAQ (with points refunded if possible) - because in any other case EnumDisplayDevices() and EnumDisplayMonitors() should do the work.

Svetlin
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question