Source von Chrisw läuft unter NT, W2K und XP
Für 9x und ME must geht's so:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40:
| procedure ScanRegEnum(var Strings: TStrings; const Key: String); var LKey : TStringList; LName : TStringList; i : Integer; Driver, PortName : String; PortSubClass : Byte; begin if not Reg.OpenKeyReadOnly(Key) then Exit; LName := TStringList.Create; Reg.GetValueNames(LName); i := LName.IndexOf('class'); if i >= 0 then begin if (Reg.GetDataType('class') = rdString) and (LowerCase(Reg.ReadString('class')) = 'ports') and (Reg.GetDataType('driver') = rdString) and (Reg.GetDataType('portname') = rdString) then begin Driver := Reg.ReadString('driver'); PortName := Reg.ReadString('portname'); if(Reg.OpenKeyReadOnly('\System\CurrentControlSet\Services\Class\'+ Driver)) and (Reg.ReadBinaryData('PortSubClass',PortSubClass,1) = 1) and (PortSubClass = 1) and (Strings.IndexOf(PortName) < 0) then Strings.Add(PortName); end; end; LName.Free; Reg.OpenKeyReadOnly(Key); if Reg.HasSubKeys then begin LKey := TStringList.Create; Reg.GetKeyNames(LKey); for i := 0 to LKey.Count - 1 do begin ScanRegEnum(Key + '\' + LKey[i]); end; LKey.Free; end; end; |
Mit USB Ports gehen beide Codes nicht!