Bonjour,

Je cherche a récupérer des données dans la base des registres pour dire que tel disque connecté en usb est sur le port x du hub y et a le n° de disque z.

Voilà ce que j'ai pu commencé à faire

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
18
19
20
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
strComputer = "." ' Use . for current machine
hDefKey = HKEY_LOCAL_MACHINE
strKeyPath = "SYSTEM\ControlSet001\Enum\USB\VID_174C&PID_55AA"
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
oReg.EnumKey hDefKey, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
  strSubKeyPath = strKeyPath & "\" & strSubkey
  oReg.EnumValues hDefKey, strSubKeyPath, arrValueNames, arrTypes
  For i = LBound(arrValueNames) To UBound(arrValueNames)
    strValueName = arrValueNames(i)
    Select Case arrTypes(i)
      Case REG_SZ
        oReg.GetStringValue hDefKey, strSubKeyPath, strValueName, strvalue
        If strValueName = "LocationInformation" Then
            MsgBox strSubkey & " -> " & strvalue
        End If
    End Select
  Next
Ceci fonctionne, mais je souhaiterais récupérer dans SYSTEM\ControlSet001\Services\disk\Enum le numéro de disque associé à strvalue

Merci de votra aide