Hello, I have run into a problem with a vb.net program I am developing, and was wondering if anyone could help.
Background:
The program runs as a service, which may be the root cause of my issue.
I have found a couple of ways of getting the screen resolution, which all report the same thing.
WMI version
Easy vb.net versionCode:Private Sub getRes() Dim objWMIService, objComputer As Object objWMIService = GetObject("Winmgmts:{impersonationLevel=impersonate,(Debug,Shutdown)}") For Each objComputer In objWMIService.InstancesOf("Win32_DisplayConfiguration") Utils.WriteToEventLog("WMIRes: " & objComputer.PelsWidth & "x" & objComputer.PelsHeight,EventLogEntryType.Information) Next End Sub
More comlplex vb.net versionCode:private sub getRes() dim Height as Integer = my.computer.screen.bounds.height dim Width as Integer = my.computer.screen.bounds.width Utils.WriteToEventLog("Res: " & Width & "x" & Height, EventLogEntryType.Information) end Sub
Code:private sub getRes() for each device in my.computer.screen.allscreens height = device.bounds.height width = device.bounds.width .....
All very straight-forward. Except that it reports back 1024x768 when the real resolution is 1280x800
If I run the code in a new project with a windows form, it reports correctly.
So, how can my service get the resolution of the screen of the device that it is running on?



LinkBack URL
About LinkBacks
Reply With Quote


