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 41
| '''''''RETRIEVE INSTALLED PRINTERS
'Dim printer As PrinterSettings.StringCollection, IdxImpParDefaut As Integer, i As Integer
'printer = Printing.PrinterSettings.InstalledPrinters
'cmbPrinters.Text = printer.Item(0)
'i = 0
'IdxImpParDefaut = 0
'For Each p In printer
' cmbPrinters.Items.Add(p.ToString())
' If p.ToString() = DefaultPrinterName() Then IdxImpParDefaut = i
' i = i + 1
'Next
'If cmbPrinters.Items.Count > 0 Then cmbPrinters.SelectedIndex = IdxImpParDefaut
'''''''RETRIEVE ALL PRINTERS
Dim oquery As ObjectQuery = New ObjectQuery("SELECT * FROM Win32_Printer")
Dim mosearcher As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher(oquery)
Dim moc As System.Management.ManagementObjectCollection = mosearcher.Get()
For Each mo As ManagementObject In moc
cmbPrinters.Items.Add(mo.Properties("name").Value.ToString())
Next mo
'''''''RETRIEVE CITRIX PRINTERS
'Dim rsConfig As RunspaceConfiguration
'rsConfig = RunspaceConfiguration.Create()
'Dim info As PSSnapInInfo
'Dim snapInException As New PSSnapInException
'info = rsConfig.AddPSSnapIn("Citrix.XenApp.Commands",
'snapInException)
'Dim myRunSpace As Runspace
'myRunSpace = RunspaceFactory.CreateRunspace(rsConfig)
'myRunSpace.Open()
'Dim pipeLine As Pipeline
'pipeLine = myRunSpace.CreatePipeline()
'Dim myCommand As New Command("Get-XAPrinter")
'pipeLine.Commands.Add(myCommand)
'Dim commandResults As Collection(Of PSObject)
'commandResults = pipeLine.Invoke()
'For Each cmdlet As PSObject In commandResults
' cmbPrinters.Items.Add(cmdlet.Properties("Printername").
' Value.ToString())
'Next |
Partager