How to capture result from a rundll32 invocation?

4.4k views Asked by At

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?

1

There are 1 answers

7
David Heffernan On BEST ANSWER

rundll32 does not give you any return value, its exit code is always zero.

I think you'll have to find another way.