如何解决win32api.ShellExecute() 函数有什么作用?
我正在学习如何用 python 打印文件。我找到了很多方法来做到这一点,我见过的最常见的方法之一是使用 win32api
模块。
import win32api
win32api.ShellExecute(0,"print",path_for_file,None,".",0)
当我运行这个程序时,文件被打印出来没有任何问题。
但问题是我不明白 win32api.ShellExecute()
函数中实际发生了什么以及它的参数的功能是什么。对于参数,我的意思是:(0,0)
谁能解释一下 win32api.ShellExecute()
函数中的每个参数的作用?
如果有人能帮助我就好了。
解决方法
基于 ShellExecute 文档:
ShellExecute(0,// NULL since it's not associated with a window
"print",// execute the "print" verb defined for the file type
path_for_file,// path to the document file to print
None,// no parameters,since the target is a document file
".",// current directory,same as NULL here
0) // SW_HIDE passed to app associated with the file type
简而言之,这与在 Windows 资源管理器中右键单击 path_for_file
文档,然后从上下文菜单中选择 print
执行的操作相同。与文件类型关联的应用使用 print
动词和 SW_HIDE
show 命令执行,这通常意味着它会静默打印文档,不显示任何 UI。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。