Bonjour a tous
je me demande si il n'y a pas un moyen de simplifier ce code
j'entends par la supprimer le besoins des 2 boucles imbriquées
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 Sub WMI() Dim oWMISrvEx As Object 'SWbemServicesEx Dim oWMIObjSet As Object 'SWbemServicesObjectSet Dim oWMIObjEx As Object 'SWbemObjectEx Dim oWMIProp As Object 'SWbemProperty Dim sWQL As String 'WQL Statement Dim n As Long 'Generic Counter sWQL = "Select * From Win32_VideoController" ' classe utilisée Set oWMISrvEx = GetObject("winmgmts:root/CIMV2") Set oWMIObjSet = oWMISrvEx.ExecQuery(sWQL) For Each oWMIObjEx In oWMIObjSet For Each oWMIProp In oWMIObjEx.Properties_ If oWMIProp.Name = "CurrentHorizontalResolution" Then Debug.Print "resolution horizontale " & oWMIProp.Value If oWMIProp.Name = "CurrentVerticalResolution" Then Debug.Print "resolution vertcale " & oWMIProp.Value Next Next End Sub
Partager