-
Mar 19th, 2015, 06:18 AM
#1
Thread Starter
Hyperactive Member
[vb2010] Fail to get max resolution on laptop with Win 8.1
With this code:
Code:
Private Function GetRes() as Size
Dim scope As New ManagementScope
Dim q = New ObjectQuery("SELECT * FROM CIM_VideoControllerResolution")
Using searcher = New ManagementObjectSearcher(scope, q)
Dim results As ManagementObjectCollection = searcher.[Get]()
Dim maxHResolution As UInt32 = 0
Dim maxVResolution As UInt32 = 0
Try
For Each item As ManagementBaseObject In results
If DirectCast(item("HorizontalResolution"), UInt32) > maxHResolution Then
maxHResolution = DirectCast(item("HorizontalResolution"), UInt32)
If DirectCast(item("verticalResolution"), UInt32) > maxVResolution Then
maxVResolution = DirectCast(item("verticalResolution"), UInt32)
End If
End If
Next
Catch icex As System.InvalidCastException
Debug.Print(icex.ToString)
Return New Size(1, 1)
Catch ex As Exception
Debug.Print(ex.ToString)
Return New Size(1, 1)
End Try
Debug.Print("Max Supported Resolution " & maxHResolution & "x" & maxVResolution)
Return New Size(CInt(maxHResolution), CInt(maxVResolution))
End Using
End Function
I get the max supported resolution of the user monitor.
The code works well.... but a user with laptop and Win 8.1 64 bit reports that the return value size is 0,0.... this means NO ERRORS ( or the return value would be 1,1), but no results...
Some idea of why this happens? May be the code don't works on laptops? Someone with laptop and Win 8.1 can please confirm? Alternative code?
Last edited by phil2000; Mar 19th, 2015 at 06:28 AM.
-
Mar 19th, 2015, 04:17 PM
#2
Re: [vb2010] Fail to get max resolution on laptop with Win 8.1
Sorry, I don't have 8.1 but does this work for you?
Code:
Dim Scope As New ManagementScope("\\.\ROOT\cimv2")
Dim Query As New ObjectQuery("SELECT * FROM CIM_VideoControllerResolution")
Dim Searcher As New ManagementObjectSearcher(Scope, Query)
Dim ObjCollection As ManagementObjectCollection = Searcher.Get
For Each ManObject As ManagementObject In ObjCollection
MessageBox.Show(ManObject("Caption"))
Next
This should popup all available resolutions.
- If my post helped you, please Rate it
- If your problem is solved please also mark the thread resolved
I use VS2015 (unless otherwise stated).
_________________________________________________________________________________
B.Sc(Hons), AUS.P, C.Eng, MIET, MIEEE, MBCS / MCSE+Sec, MCSA+Sec, MCP, A+, Net+, Sec+, MCIWD, CIWP, CIWA
I wrote my very first program in 1979, using machine code on a mechanical Olivetti teletype connected to an 8-bit, 78 instruction, 1MHz, Motorola 6800 multi-user system with 2k of memory. Using Windows, I dont think my situation has improved.
-
Mar 19th, 2015, 06:03 PM
#3
Re: [vb2010] Fail to get max resolution on laptop with Win 8.1
I doubt wmi will work beyond xp with that query at a guess.
-
Mar 19th, 2015, 06:07 PM
#4
Thread Starter
Hyperactive Member
Re: [vb2010] Fail to get max resolution on laptop with Win 8.1
@ bulldog
The code works... since is EXACTLY like mine....
If I add to my "For Each code" : " Debug.WriteLine(item("Caption").ToString)" I obtain exactly what you suggest....
-
Mar 19th, 2015, 06:11 PM
#5
Re: [vb2010] Fail to get max resolution on laptop with Win 8.1
That was why I asked, if you strip the code down to just what I posted, does it give you the list of resolutions you're looking for. If you see the maximum is there (on Win8) then you already have the solution.
- If my post helped you, please Rate it
- If your problem is solved please also mark the thread resolved
I use VS2015 (unless otherwise stated).
_________________________________________________________________________________
B.Sc(Hons), AUS.P, C.Eng, MIET, MIEEE, MBCS / MCSE+Sec, MCSA+Sec, MCP, A+, Net+, Sec+, MCIWD, CIWP, CIWA
I wrote my very first program in 1979, using machine code on a mechanical Olivetti teletype connected to an 8-bit, 78 instruction, 1MHz, Motorola 6800 multi-user system with 2k of memory. Using Windows, I dont think my situation has improved.
-
Mar 19th, 2015, 06:13 PM
#6
Thread Starter
Hyperactive Member
Re: [vb2010] Fail to get max resolution on laptop with Win 8.1
Originally Posted by ident
I doubt wmi will work beyond xp with that query at a guess.
????? The code works very well in Seven. I have NOT Win 8.1 so I can't test if it works there.
Anyhow: some DIFFERENT code to get all available resolutions?? (Note: the API EnumDisplaySettings (user32) seems don't work with Seven and more...)
-
Mar 19th, 2015, 06:16 PM
#7
Thread Starter
Hyperactive Member
Re: [vb2010] Fail to get max resolution on laptop with Win 8.1
@bulldog
But as already I said.... the problem is that on a Laptop with Win 8.1 this code DONT' WORKS.
-
Mar 19th, 2015, 06:18 PM
#8
Re: [vb2010] Fail to get max resolution on laptop with Win 8.1
It was a guess. I can confirm it wont work with 8.1, i will have a look at it tomorrow if no one has solved it..
-
Mar 22nd, 2015, 06:37 PM
#9
Thread Starter
Hyperactive Member
Re: [vb2010] Fail to get max resolution on laptop with Win 8.1
Originally Posted by ident
It was a guess. I can confirm it wont work with 8.1, i will have a look at it tomorrow if no one has solved it..
Up!
Some news ident?
Someone knows some link where to submit to Microsoft the bug? (I think that if WMI don't works on Win 8.1... this is a .Net bug... or not?)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|