I assume you mean the client mapped printers from the user's workstation, if
so then you need to use the WTSQuerySessionInformation() api function to get
the session ID number, as shown here
***********************
Option Explicit
Private Declare Function WTSQuerySessionInformation Lib "wtsapi32" _
Alias "WTSQuerySessionInformationA" (ByVal hServer As Long, _
ByVal SessionID As Long, ByVal WTSInfoClass As Long, _
ByRef ppBuffer As Long, ByRef lLen As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Const WTS_CURRENT_SERVER_HANDLE As Long = 0
Private Const WTS_CURRENT_SESSION As Long = -1
Public Function GetTSSessionID() As Long
Dim sVal As String
Dim lVal As Long
Dim intVal As Integer
Dim lRet As Long
Dim lLen As Long
Dim lErr As Long
Dim I As Long
Dim sIP As String
Dim lBufferAddress As Long
lRet = WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, _
WTS_CURRENT_SESSION, _
4, _
lBufferAddress, _
lLen)
' copying the buffer to a VB string
If lLen > 0 Then
lVal = 0
CopyMemory lVal, ByVal lBufferAddress, lLen
GetTSSessionID = lVal
End If
If lRet = 0 Then
lErr = Err.LastDllError
GetTSSessionID = -1
End If
End Function
**********************************
In your DiscoverPrinters add
Dim strSession As String
Dim lngSession As Long
lngSession = GetTSSesssionID()
If lngSession > 0 Then strSession = "/Session " & lngSession
Then you test the devicename to see if it has a double underscore at the
beginning, if it has test to see if the devicename contains the strSession
value.

Signature
regards
Ian
*** inavlid email address - change country code to full country name
> I writting a VB6 program that will run when a user logs into a terminal
> server. I would like to be able to get all the printer names that come over
[quoted text clipped - 17 lines]
>
> Any ideas on how to grab just the printers specific to the user?
Mkjo - 08 Jul 2008 20:30 GMT
That works great.
Thanks Ian.
> I assume you mean the client mapped printers from the user's workstation, if
> so then you need to use the WTSQuerySessionInformation() api function to get
[quoted text clipped - 83 lines]
> >
> > Any ideas on how to grab just the printers specific to the user?