在用vb.net实现选择打印机这个功能的开发过程中,遇到了问题,查了很多文章,都没有解决,最终试出来了一个。标注的地方是重点。
Dim MyProcess As New Process
MyProcess.StartInfo.CreateNoWindow = False
MyProcess.StartInfo.Verb = "print"
MyProcess.StartInfo.FileName = printFile
Dim printerName As String = ComboBoxPrint.Text
Shell(String.Format("rundll32 printui.dll,PrintUIEntry /y /n ""{0}""", printerName))
MyProcess.Start()
MyProcess.WaitForExit(20000)
If MyProcess.HasExited = False Then
MyProcess.Kill()
Me.Close()
IsPrint = 1
IsPrinted(ConfEnvPath, "IsPrinted", "is_printed ")
Else
Me.Close()
End If