lpr命令无法在Win 7中使用我的C#程序

Sun*_*eep 5 c# winapi lpr

我有程序使用'lpr'命令将文件发送到打印机.我安装了Windows SDK 7.1.它在32位Windows 7系统中运行良好,但在64位Windows 7中无法运行.

            Process proc = new Process();
            proc.StartInfo.FileName = "lpr";
            proc.StartInfo.WorkingDirectory = GlobalConstants.outBaseDir;
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            proc.StartInfo.Arguments = " -S " + GlobalConstants.printerIP + " -P RAW " + filePath;
            proc.Start();
Run Code Online (Sandbox Code Playgroud)

它抛出了一个执行.

Sun*_*eep 9

我终于得到了我的问题的答案.

第一步:我必须启用"LPR端口监视器".这可以通过"控制面板/程序和功能/打开或关闭Windows功能"来完成.在对话框中展开"打印和文档服务".检查"LPR端口监视器".

第2步:安装Windows SDK 7.1时.它会将lpr.exe和相关文件复制到"C:\ Windows\winsxs\amd64_microsoft-windows-p..ting-lprportmonitor_xxxx ...".将文件lpr.exe,lprhelp.dll和lprmonui.dll复制到C:\ Windows\sysWOW64文件夹中.

而已!!!

参考:http://www.tomshardware.com/forum/240019-44-error-windows