任何人都可以帮助我使用processinfo打印文件 [英] Can anyone help me to get a file to print with processinfo

查看:136
本文介绍了任何人都可以帮助我使用processinfo打印文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试使用processinfo打印文件。我遇到的问题是,当它被设置为隐藏窗口时,它会在没有打印的情况下停止,并且正在等待我做某事。如果我将其更改为显示窗口,则该过程显示打印机选择对话框。我需要的是它自动选择默认打印机,然后打印。这是我正在使用的代码:





Dim info As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo(strFiles( i).ToString)

Dim dpn As String = DefaultPrinterName()

info.Arguments = Chr(34)+ dpn + Chr(34)

info.CreateNoWindow = True

info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden

info.UseShellExecute = True

info.Verb =打印



我尝试的任何内容都不允许自动选择打印机。我认为这可能是打印机驱动程序的问题,所以我甚至尝试将默认打印机更改为物理打印机,但也没有用。



我尝试过什么:



1.尝试使用真正的打印机

2.删除.arguments信息

3.更改它以显示窗口(然后显示默认突出显示的打印机要求我点击确定。

4.尝试'printto'动词

Hi All,
I am trying to print a file using processinfo. The problem i am having is that when it is set to hide the window it just stops without printing, and is waiting for me to do something. If i change it to display a window the process displays the printer selection dialogue. what i need is for it to automatically select the default printer and just print. Here is the code i am using:


Dim info As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo(strFiles(i).ToString)
Dim dpn As String = DefaultPrinterName()
info.Arguments = Chr(34) + dpn + Chr(34)
info.CreateNoWindow = True
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
info.UseShellExecute = True
info.Verb = "print"

Nothing i try allows the printer to be automatically selected. I thought it might be a printer driver issue so i even tried changing the default printer to a physical printer but that didnt work either.

What I have tried:

1. tried a real printer
2. removed the .arguments info
3. changed it to display the window (it then displayed printers with the default highlighted asking me to click ok.
4. tried the 'printto' verb

推荐答案

我无法重现你的问题。我使用了你的代码进行了小修改:

I cannot reproduce your issue. I have used your code with small modification:
Dim info As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo("D:\data.txt")
With info
    .CreateNoWindow = True
    .WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
    .UseShellExecute = True
    .Verb = "print"
End With
Process.Start(info)'start printing



以上代码工作正常并在默认打印机上打印文本文件。

好​​像,你忘了开始处理。


Above code is working fine and prints text document on default printer.
Seems, you forgot to start process.

这篇关于任何人都可以帮助我使用processinfo打印文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆