如何捕获 rundll32 调用的结果?
我被 Java 中这个旧错误/缺失功能所困扰:
https ://bugs.java.com/bugdatabase/view_bug;jsessionid=b2ac8ea11f05c16d948e24d36fb5?bug_id=4673406
问题是,Java 标准打印对话框中的“属性”按钮在 Windows 上似乎总是处于禁用状态。仅当 PrintService.getServiceUIFactory() 返回不为 null 的内容时,才会启用该按钮。不幸的是 Win32PrintService 实例总是返回 null。总是。
通过谷歌搜索,我发现您可以通过调用 rundll32 来调用 Windows 自己的打印属性对话框:
rundll32 printui.dll,PrintUIEntry /e /n "name of printer here"
我希望我可以使用它来规避 Win32PrintService 中的错误/缺失功能。但是,我不知道如何查询 PrintUIEntry 对话框以获取用户的选择。
换句话说,如何获得上述 rundll32 调用的结果? (如果我必须用 C/JNI 编写一些东西并直接使用 Windows API,那就这样吧。不过,我宁愿不这样做。)
或者有更好的方法来解决这个问题吗?
I've been bitten by this old bug/missing feature in Java:
https://bugs.java.com/bugdatabase/view_bug;jsessionid=b2ac8ea11f05c16d948e24d36fb5?bug_id=4673406
The thing is that the "Properties" button in Java's standard print dialog is seemingly always disabled on Windows. The button is only enabled if PrintService.getServiceUIFactory() returns something that isn't null. Unfortunately Win32PrintService instances always return null. Always.
By googling, I discovered that you can invoke Windows' own print properties dialog thingy by calling rundll32:
rundll32 printui.dll,PrintUIEntry /e /n "name of printer here"
I'm hoping I can use this to circumvent the bug/missing feature in Win32PrintService. However, I don't know how I can query the PrintUIEntry-dialog for the user's choices.
In other words, how can I get a result of the above rundll32-invocation? (If I have to write something in C/JNI and use the Windows API directly, so be it. I'd rather not, though.)
Or is there a better way to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
rundll32 不会给您任何返回值,它的退出代码始终为零。
我想你必须找到另一种方法。
rundll32 does not give you any return value, its exit code is always zero.
I think you'll have to find another way.