python - 在 ShellExecute 中,如何指定页面范围、托盘等打印参数?

标签 python windows

这是我使用 Python 在 Windows 机器上打印 pdf 文件的代码。我安装了 adobe Acrobat Reader 以帮助打印。

win32api.ShellExecute(0,"print",file_path,"NPIAC1EC3 (HP LaserJet Pro MFP M226dw)",".",3)  

如何添加其他选项来提及诸如打印机托盘/页面源、页面范围等内容?

我已阅读有关 ShellExecute 的文档来自 MSDN。

我在文档中看到有一个lpParameters(我完全猜测这是我指定打印参数的地方)但没有解释如何将它与“打印”参数一起使用.

最佳答案

链接的文档说明你想要什么是不可能的。注释摘录(强调我的):

语法:

HINSTANCE ShellExecute(
  _In_opt_ HWND    hwnd,
  _In_opt_ LPCTSTR lpOperation,
  _In_     LPCTSTR lpFile,
  _In_opt_ LPCTSTR lpParameters,
  _In_opt_ LPCTSTR lpDirectory,
  _In_     INT     nShowCmd
);

Parameters
...

  • lpOperation [in, optional]

    Type: LPCTSTR

    A pointer to a null-terminated string, referred to in this case as a verb, ... The following verbs are commonly used:
    ...

    print

    Prints the file specified by lpFile. If lpFile is not a document file, the function fails.

因此,当您将“print”用作动词时,lpFile 应为文档文件

...

  • lpParameters [in, optional]

    Type: LPCTSTR

    If lpFile specifies an executable file, this parameter is a pointer to a null-terminated string that specifies the parameters to be passed to the application. The format of this string is determined by the verb that is to be invoked. If lpFile specifies a document file, lpParameters should be NULL.

所以当你使用print作为动词时,lpFile必须是文档文件,lpParameters必须为null:没有规定将附加参数传递给 ShellExecute 打印操作。

关于python - 在 ShellExecute 中,如何指定页面范围、托盘等打印参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50365451/

相关文章:

python - 如何创建关联矩阵

python - 如何从命令行获取python安装路径

asp.net - 是否有任何 CMS 可以轻松地重新创建此模型?

python - LabelBinarizer 将多数类编码为 1 而不是 0

python - Python 2.7 的 Jupyter 安装失败

python - except block 未捕获 ipython 笔记本中的异常

python - 如何计算 nfft

windows - 如果 Steam 可以映射 Xbox 360 Controller 上的指南按钮,为什么我不能

windows - Git 连接问题。 "fatal: unable to connect to github.com....."

c++ - 从新线程调用时出现 COM 0x8001010E 错误