I need to get the desktop resolution from a Delphi program.
However, if the program is not DPI aware Windows will lie about the real screen resolution so all kind of problems will rise from here.
Since it is too much work to make the program fully DPI aware (and I try to AVOID the WMI solution) I am thinking using a quick dirty trick: I will create a microscopic DPI-aware console program that will read the real resolution.
The main program will use start this little program (hidden) every time it needs the resolution. Seems simple enough to do. Right?
Question 1: Do I have another (better) option?
Question 2: I tried to create that little program. Although is has something like 10 lines of code its EXE size is 2.1MB and its memory footprint is 5.4MB!
Can I make it smaller? If the program is small enough (under 1MB RAM) I could leave it run all the time without pissing off the users.
Question 1: Do I have another (better) option?
You can use WMI as per your earlier question: How to obtain the real screen resolution in a High DPI system?
Question 2: I tried to create that little program. Although is has something like 10 lines of code its EXE size is 2.1MB and its memory footprint is 5.4MB! Can I make it smaller?
The trick is to avoid using any VCL units, and minimising the number of RTL units that you use. Your goal should be to use the Windows
unit only. Or even avoid it and create your own Windows API imports for just the functions that you need.
Another option would be to create this program with a different programming language, one that was better able to remove dead code. I'd probably do this with a short C program.