AW: Zusatzfrage: Port
22.09.2005 12:01:56
K.Rola
Hallo,
geht alles und noch viel mehr:
Option Explicit
Private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" ( _
ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long) As Long
Private Const MP = 16
Private sName(MP) As String
Private sDriver(MP) As String
Private sPort(MP) As String
Private iCount As Integer
Sub Printer_List()
Dim sBuf As String, i As Integer
sBuf = Space$(8192)
GetProfileString "PrinterPorts", vbNullString, "", sBuf, Len(sBuf)
GetName sBuf
GetPort
For i = 0 To iCount
Tabelle1.Cells(i + 1, 1) = sName(i)
Tabelle1.Cells(i + 1, 2) = sPort(i)
Tabelle1.Cells(i + 1, 3) = sDriver(i)
Next
End Sub
Private Sub GetName(ByVal sBuf As String)
Dim i As Integer, stName As String
iCount = 0
Do
i = InStr(sBuf, Chr(0))
If i > 0 Then
stName = Left$(sBuf, i - 1)
If Len(Trim$(stName)) > 0 Then
sName(iCount) = Trim$(stName)
iCount = iCount + 1
End If
sBuf = Mid$(sBuf, i + 1)
Else
If Len(Trim$(sBuf)) > 0 Then
sName(iCount) = Trim$(sBuf)
iCount = iCount + 1
End If
sBuf = ""
End If
Loop While (i > 0) And (iCount < MP)
End Sub
Private Sub GetPort()
Dim sBuf As String
Dim i As Integer
For i = 0 To iCount - 1
sBuf = Space$(1024)
GetProfileString "PrinterPorts", sName(i), "", sBuf, Len(sBuf)
GetDr_Port sBuf, sDriver(i), sPort(i)
Next
End Sub
Private Sub GetDr_Port(ByVal bf As String, dn As String, pp As String)
Dim iD As Integer, iP As Integer
dn = ""
pp = ""
iD = InStr(bf, ",")
If iD > 0 Then
dn = Left$(bf, iD - 1)
iP = InStr(iD + 1, bf, ",")
If iP > 0 Then
pp = Mid$(bf, iD + 1, iP - iD - 1)
End If
End If
End Sub
Gruß K.Rola