如何列出已连接的打印机
怎么列出已连接的打印机PR为Combobox控件Dim D As PrinterFor Each D In Printers列出系统打印设备If D.D
怎么列出已连接的打印机
PR为Combobox控件
Dim D As Printer
For Each D In Printers '列出系统打印设备
If D.DeviceName <> "Adobe PDF" Then PR.AddItem D.DeviceName
Next D
PR.ListIndex = 0
1.以上可以在VB6中列出打印机,但是在VB2010里面要怎么改呢?我试过好多都有错误,请帮帮忙,实在没办法才转到VB2010上的。
2.另外有一个想法就是,只显示连接了的,如果安装了打印机但是已经断开的就不显示,这个功能又怎么实现? vb2010 VB 打印机
[解决办法]http://www.vb-helper.com/howto_net_list_printers.html
Imports System.Drawing.Printing
Private Sub Form1_Load(ByVal sender As Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
Dim pkInstalledPrinters As String
' Find all printers installed
For Each pkInstalledPrinters In _
PrinterSettings.InstalledPrinters
cboInstalledPrinters.Items.Add(pkInstalledPrinters)
Next pkInstalledPrinters
' Set the combo to the first printer in the list
cboInstalledPrinters.SelectedIndex = 0
End Sub
[解决办法]找到名字之后可以用WMI去查win32_Printer.Availability