我怎么能要求的Windows打印文档?文档、我怎么能、Windows

2023-09-05 00:14:01 作者:猎心人

欲各种类型的(编程)打印文件,通过询问视窗做(使用缺省关联的应用程序)。我怎样才能做到这一点(在.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);