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
| Option Explicit
Private Declare Function GetProfileSection& Lib "kernel32" Alias "GetProfileSectionA" ( _
ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal lngSize As Long)
Sub Liste_Imprimantes_Ports()
Dim A As String, rep As Long, cpt As Long, pos As Long, T() As String
A$ = Space(2048)
rep = GetProfileSection("devices", A, 2048)
If rep > 0 Then
ShTst.Cells.Clear
A = Trim$(Replace(A, Chr(0), ""))
Do Until A = ""
cpt = cpt + 1
ReDim Preserve T(1 To 2, 1 To cpt)
pos = InStr(1, A, "=") - 1
T(1, cpt) = Mid$(A, 1, pos)
pos = InStr(1, A, ",") + 1
T(2, cpt) = Mid$(A, pos, InStr(1, A, ":") + 1 - pos)
A$ = Mid$(A, InStr(1, A, ":") + 1)
With ShTst
.Cells(cpt, 1) = T(1, cpt)
.Cells(cpt, 2) = T(2, cpt)
End With
Loop
End If
End Sub |