Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

API for Monitor Detection

Posted on 2003-03-12
2
Medium Priority
?
780 Views
Last Modified: 2011-09-20
I want to know how I can get the monitor name(or type) connect to my
display card,if mutiple display in use,how enum all of them?
0
Comment
Question by:qzdmmx
2 Comments
 
LVL 3

Expert Comment

by:emadat
ID: 8119798
For the monitors count, you can use this function:

function MonitorsCount: integer;
var
    TM : TScreen;
begin
    TM := TScreen.Create(Nil);
    try
     result := TM.MonitorCount;
    finally
     TM.Free;
    end;
end;

you can get the properties of each monitor using the Monitors collection of the TScreen object "TM.Monitors in our example".
0
 
LVL 1

Accepted Solution

by:
Noturno earned 75 total points
ID: 8120598
For give me for my poor english (i'm brazilian)

You can get all monitor information by using an API function called GetMonitorInfo:

BOOL GetMonitorInfo(
  HMONITOR hMonitor,  // handle to display monitor
  LPMONITORINFO lpmi  // display monitor information
);

You can get the monitor handle by using the TMonitor class:

//-------------------------
procedure GetMonitors;
var
   A: Integer;
   MI: LPMONITORINFO;
begin
   with Screen Do
   begin
      for A:= o to MonitorCount - 1 Do
      begin
         GetMonitorInfo(Monitors[A].Handle, MI);
         // Display information of the monitor using MI
      end;
   end;
end;
//-------------------------

You will need to implement the structure of LPMONITORINFO:

typedef struct tagMONITORINFO {
  DWORD  cbSize;
  RECT   rcMonitor;
  RECT   rcWork;
  DWORD  dwFlags;
} MONITORINFO, *LPMONITORINFO;

I don't translate it to pascal because I've copied it from the msdn. You can get this information at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/monitor_27e7.asp
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

580 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