我想要没有显示窗口的打印过程 [英] I want print process without show window

查看:65
本文介绍了我想要没有显示窗口的打印过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 make_print(); 
using(Process p = new Process())
{
string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
p.StartInfo.FileName = systemPath + @\ rundll32.exe;
p.StartInfo.Arguments = systemPath + @\mshtml.dll,PrintHTML+ @D:\Program\Report \+ test.ToString()+ @。html + @;
p.Start();
p.Close();
p.Dispose();

我尝试过:

< pre> make_print();
using(Process p = new Process())
{
string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
p.StartInfo.FileName = systemPath + @\ rundll32.exe;
p.StartInfo.Arguments = systemPath + @\mshtml.dll,PrintHTML+ @D:\Program\Report \+ test.ToString()+ @。html + @;
p.Start();
p.Close();
p.Dispose();
}

解决方案

尝试:

 p.StartInfo .CreateNoWindow =  true ; 

但是你应该等到它关闭并处理它之前退出:

 p.Start(); 
p.WaitForExit();

您无需手动关闭或处置您的流程,使用块为您执行此操作


 make_print();
            using (Process p = new Process())
            {
                string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
                p.StartInfo.FileName = systemPath + @"\rundll32.exe";
                p.StartInfo.Arguments = systemPath + @"\mshtml.dll,PrintHTML """ + @"D:\Program\Report\" + test.ToString() + @".html" + @"""";
                p.Start();
                p.Close();
                p.Dispose();

What I have tried:

<pre> make_print();
            using (Process p = new Process())
            {
                string systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System);
                p.StartInfo.FileName = systemPath + @"\rundll32.exe";
                p.StartInfo.Arguments = systemPath + @"\mshtml.dll,PrintHTML """ + @"D:\Program\Report\" + test.ToString() + @".html" + @"""";
                p.Start();
                p.Close();
                p.Dispose();
            }

解决方案

Try:

p.StartInfo.CreateNoWindow = true;

But you should probably wait for it to exit before you Close and Dispose it:

p.Start();
p.WaitForExit();

You don't need to manually Close or Dispose your processes, the using block does that for you.


这篇关于我想要没有显示窗口的打印过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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