Intercepting print jobs by hooking createDCW and createDCA
Posted on 2006-06-09
I have been trying to implement password protected printing by hooking createDCW and createDCA and either ‘doing nothing’ or passing the call onto the OS depending on whether the correct password has been entered.
‘doing nothing’ appeared to work, and prevent printing, for applications like Notepad, but caused problems with apps like MS Excel which would get stuck in a loop showing an error.
So in the hook I tried returning NULL, the value returned by createDCW and createDCA if they fail. This caused MS Excel to simply close after trying to print.
I then tried repeating the createDCW/ createDCA as normal, but following it with an AbortDoc, but this seems to allow the print job to get to the print queue, even though abortdoc returns 1.
Any suggestions to what is going wrong?