I'm trying to get the size of the Windows' desktop (the whole thing, not just a single screen) from inside a service that I've written.
In WinForms -- the standard C# method of:
SystemInformation.VirtualScreen.Width
SystemInformation.VirtualScreen.Height
seems to work (if you import the Winforms DLL, which I want to avoid) -- but it returns the wrong value. The desktop size is 2048x768
(2 screens), but the service reports 1024x768
(presumably it only picks up on one of the screens.)
Checking the option for the service to interact with the desktop has no effect.
Any thoughts?
Edit:
The solutions posted at C#: Get complete desktop size? don't work inside of a service. They all report the wrong value.
Interestingly, it seems like the value that is reported varies and is of no relation to the actual desktop size (some machines report 800x600
even though a single display on that machine is a much higher resolution.)
So -- any more ideas? Dropping into the registry and/or to the command line is OK. The only restriction is that I can't launch a winforms app to figure it out.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…