我怎么能要求的Windows打印文档? [英] How can I ask Windows to print a document?

查看:159
本文介绍了我怎么能要求的Windows打印文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欲各种类型的(编程)打印文件,通过询问视窗做(使用缺省关联的应用程序)。我怎样才能做到这一点(在.NET或C ++ / Win32 API的)?

I want to (programmatically) print documents of various types, by asking Windows to do it (using the default associated application). How can I do this (in .NET or C++/Win32 API)?

例如,如果我有MS Office和Acrobat Reader软件安装到计算机上,PDF文件应由Acrobat Reader软件打印和DOC文件应该由MS Word中打印。但是,如果我没有安装微软Office,DOC文件应该使用写字板或OpenOffice.org Writer中印如果是后者安装,或任何应用程序,目前该类型文件的默认关联。

For example, if I have MS Office and Acrobat Reader installed on the machine, PDF files should be printed by Acrobat Reader, and DOC files should be printed by MS Word. But if I don't have MS Office installed, DOC files should be printed using Wordpad, or OpenOffice.org Writer if the latter is installed, or whatever application is currently the default association for that type of files.

推荐答案

尝试使用的 ShellExecute的功能。

例如,在C:

 ShellExecute(my_window_handle, "print", path_to_file, NULL, NULL, SW_SHOW);

这篇关于我怎么能要求的Windows打印文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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