Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ShellExecuteEx Printto

54 views
Skip to first unread message

amdrit

unread,
Jun 10, 2008, 10:45:54 AM6/10/08
to
Hello Everyone.

I have a need to print some PDF documents in the background from my
application. There are a couple things that aren't clear or my expectation
is too high.

My first issue is that I am only able to get Acrobat to display minimized, I
would prefer it never appeared. I use the SW_HIDE constant as my value for
SHELLEXECUTEINFO.nShow.

I could live with that if I knew when the printing was complete so that I
could close the application down myself. This brings me to me second issue,
how do I obtain the windows handle from the hProcess?

My thinking is that I could PostMessage WM_CLOSE after a timeout period get
Acrobat to close up for me. Perhaps that is the wrong approach, since it is
possible for Acrobat to already be open and the user could have another PDF
file up.

I am looking to simulate the Windows Explorer, Right Click, Print
functionality. However, I do have some caveats:

1. I want to specify an alternate printer (this seems to work well).
2. I want the documents to be printed to spawn a new instance of Acrobat as
to not interfear with existing spawns..
3. I want Acrobat to go away when the printing is complete. Currently,
even Explorer leaves one instance open.

ShellInfo.cbSize = Len(ShellInfo)
ShellInfo.lpVerb = strVerb '"printto"
ShellInfo.lpFile = strFileName
ShellInfo.lpParameters = """" & strPrinterUNC & """"
ShellInfo.nShow = SW_HIDE
ShellInfo.fMask = SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_FLAG_DDEWAIT

iRet = ShellExecuteEX(ShellInfo)

if (iRet and (ShellInfo.hInstApp > 32)) then

'Monitor until GetExitCode fails or returns a closed code

'
' Here is where I would like to close Acrobat after some time has elapsed
' or perhaps a message is captured
' To capture a message though, I need the windows handle
' who is hinding the windows handle from me.

CloseHandle ShellInfo.hProcess

end if

If anyone has any thoughts on this, please share them.


mark.tunna...@googlemail.com

unread,
Jul 11, 2008, 1:03:34 PM7/11/08
to
There are some APIs for controlling the Acrobat Reader through DDE or
ActiveX. It's possible they will allow you to do what you want.

http://www.adobe.com/devnet/acrobat/interapplication.html

0 new messages