OVH Cloud OVH Cloud

Installation d'imprimante !!

1 réponse
Avatar
Jeff
Bonjour, juste une petite question, comment installer une nouvelle
imprimante sur un poste NT via Visual-Basic ?

Merci Jf

1 réponse

Avatar
Bismark Prods
sPrinterName: Le nom de l'imprimante
sDriver: La chaine de caractère qui indique le driver
sPort: Le port de l'imprimante
sComment: Le commentaire associé à l'imprimante

Exemple:

dim variable as string
variable = InstallPrinter("Epson", "Epson Stylus COLOR 440", "LPT1:", ,"Mon
imprimante")
MsgBox "Imprimante ajoutée: " & variable

Ti£oi$

Private Type PRINTER_INFO_2
pServerName As String
pPrinterName As String
pShareName As String
pPortName As String
pDriverName As String
pComment As String
pLocation As String
pDevMode As Long
pSepFile As String
pPrintProcessor As String
pDatatype As String
pParameters As String
pSecurityDescriptor As Long
Attributes As Long
Priority As Long
DefaultPriority As Long
StartTime As Long
UntilTime As Long
Status As Long
cJobs As Long
AveragePPM As Long
End Type

Private Declare Function AddPrinter Lib "winspool.drv" Alias "AddPrinterA" _
(ByVal pName As String, ByVal Level As Long, pPrinter As Any) As Long
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As
_
Long) As Long


Function InstallPrinter(ByVal sPrinterName As String, ByVal sDriver As
String, _
Optional ByVal sPort As String = "LPT1:", Optional sServer As String, _
Optional sComment As String) As Boolean
Dim hPrinter As Long
Dim PI As PRINTER_INFO_2

With PI
.pPrinterName = sPrinterName
.pDriverName = sDriver
.pPortName = sPort
.pServerName = sServer
.pComment = sComment
.pPrintProcessor = "WinPrint"
.Priority = 1
.DefaultPriority = 1
.pDatatype = "RAW"
End With
hPrinter = AddPrinter(sServer, 2, PI)

If hPrinter <> 0 Then
ClosePrinter hPrinter
InstallPrinter = True
End If

End Function


"Jeff" a écrit dans le message de
news:3fc0b481$0$2786$
Bonjour, juste une petite question, comment installer une nouvelle
imprimante sur un poste NT via Visual-Basic ?

Merci Jf