Mam aplikację, która nie używa form (bez GUI, nie używam klasy TForm). Program ma za zadanie odpalić inny program, wykonać kilka akcji i zamknąć się po zamknięciu uruchomionej aplikacji. Niestety, w takim przypadku nie mam dostępu do klasy TScreen, która pozwala w prosty i szybki sposób pobrać informacje o ekranie, rozdzielczości oraz DPI.
Używając klasę TScreen jest to proste i szybkie.
Przykład:
var
i : integer;
MyMonitor : TMonitor;
begin
Memo1.Lines.Clear;
for i:= 0 to Screen.MonitorCount-1 do
begin
Memo1.Lines.Add('MONITOR: ' + inttostr(i));
Memo1.Lines.Add(#9 + 'Pixels Per Inch: ' + inttostr(Screen.Monitors[i].PixelsPerInch));
Memo1.Lines.Add(#9 + 'Monitor Handle: ' + inttostr(Screen.Monitors[i].Handle));
Memo1.Lines.Add(#9 + 'Monitor Number: ' + inttostr(Screen.Monitors[i].MonitorNum));
Memo1.Lines.Add(#9 + 'Left: ' + inttostr(Screen.Monitors[i].Left));
Memo1.Lines.Add(#9 + 'Top: ' + inttostr(Screen.Monitors[i].Top));
Memo1.Lines.Add(#9 + 'Width: ' + inttostr(Screen.Monitors[i].Width));
Memo1.Lines.Add(#9 + 'Height: ' + inttostr(Screen.Monitors[i].Height));
Memo1.Lines.Add(#9 + 'BoundsRect Width: ' + inttostr(Screen.Monitors[i].BoundsRect.Width));
Memo1.Lines.Add(#9 + 'BoundsRect Height: ' + inttostr(Screen.Monitors[i].BoundsRect.Height));
Memo1.Lines.Add(#9 + 'BoundsRect Left: ' + inttostr(Screen.Monitors[i].BoundsRect.Left));
Memo1.Lines.Add(#9 + 'BoundsRect Top: ' + inttostr(Screen.Monitors[i].BoundsRect.Top));
Memo1.Lines.Add(#9 + 'BoundsRect Right: ' + inttostr(Screen.Monitors[i].BoundsRect.Right));
Memo1.Lines.Add(#9 + 'BoundsRect Bottom: ' + inttostr(Screen.Monitors[i].BoundsRect.Bottom));
Memo1.Lines.Add(#9 + 'WorkareaRect Width: ' + inttostr(Screen.Monitors[i].WorkareaRect.Width));
Memo1.Lines.Add(#9 + 'WorkareaRect Height: ' + inttostr(Screen.Monitors[i].WorkareaRect.Height));
Memo1.Lines.Add(#9 + 'WorkareaRect Left: ' + inttostr(Screen.Monitors[i].WorkareaRect.Left));
Memo1.Lines.Add(#9 + 'WorkareaRect Top: ' + inttostr(Screen.Monitors[i].WorkareaRect.Top));
Memo1.Lines.Add(#9 + 'WorkareaRect Right: ' + inttostr(Screen.Monitors[i].WorkareaRect.Right));
Memo1.Lines.Add(#9 + 'WorkareaRect Bottom: ' + inttostr(Screen.Monitors[i].WorkareaRect.Bottom));
Memo1.Lines.Add('');
MyMonitor :=Screen.MonitorFromWindow(Self.Handle);
Memo1.Lines.Add(#9 + 'Current Monitor: ' + inttostr(MyMonitor.MonitorNum));
end;
end;
Pytanie, za 100 punktów, jak pobrać informacje jak powyżej (bieżąca rozdzielczość oraz DPI monitora(ów), monitor na którym odpalona jest dana aplikacja)?
Jakoś nie mogę znaleźć w miarę prostego rozwiązania...
Ps: Nie chcę używać WMI, przy użyciu którego to nie problem.
Ps: W ostateczności mógłbym dodać TForm do programu i ukryć formatkę, ale zwiększa to drastycznie rozmiar programu i jest bez sensu... a to ma być tylko program uruchamiający i ustawiający kilka parametrów (launcher).
-Pawel