2008. május 7., szerda

How to determine the RAM size of the display adapter


Problem/Question/Abstract:

Which Win API function can give me the amount of memory of my computer's display adapter?

Answer:

EnumDisplaySettings gives you the different settings for the adapter. The amount of RAM can then be calculated (width * height * colors).


procedure TForm1.Button1Click(Sender: TObject);
var
  DevMode: TDeviceMode;
  i, m, max: Integer;
begin
  max := 0;
  i := 0;
  while EnumDisplaySettings(nil, i, DevMode) do
  begin
    with DevMode do
      m := Round(dmPelsWidth * dmPelsHeight * (dmBitsPerPel / 8));
    if m > max then
      max := m;
    inc(i);
  end;
  label1.caption := IntToStr(max);
end;

Nincsenek megjegyzések:

Megjegyzés küldése