Page 1 of 1

Printing from a Windows Service

Posted: Mon Jun 08, 2009 4:13 pm
by rozeboosje
I've created a Windows Service using VB6, and I am using it to produce PDF documents through BullZip

This is the relevant VB Code that is executed:

'--- First create the Printer Settings Object - depending on whether they have the BullZip or bioPDF object installed:
On Error Resume Next
Err.Clear
Set oBX = CreateObject("BullZIP.PDFPrinterSettings")
If oBX Is Nothing Then
Set oBX = CreateObject("bioPDF.PDFPrinterSettings")
End If

'--- Get the BullZip PDF Printer
For Each objP In Printers
If InStr(1, objP.DeviceName, "bull", vbTextCompare) > 0 Then
Exit For
End If
Next

If objP Is Nothing Then
Set oBX = Nothing
Exit Do
End If

If InStr(1, objP.DeviceName, "bull", vbTextCompare) = 0 Then
Set oBX = Nothing
Set objP = Nothing
Exit Do
End If

'--- At this point we found the BullZip printer on the system
Set Printer = objP
Printer.PaperSize = 9 '--- 9 = A4

oBX.SetValue "Output", strPDF
oBX.SetValue "ConfirmOverwrite", "no"
oBX.SetValue "ShowSaveAS", "never"
oBX.SetValue "ShowSettings", "never"
oBX.SetValue "ShowPDF", "no"
oBX.SetValue "ShowProgress", "no"
oBX.SetValue "ShowProgressFinished", "no"
oBX.SetValue "RememberLastFileName", "no"
oBX.SetValue "RememberLastFolderName", "no"
oBX.WriteSettings True

'--- Do my stuff and finally
Printer.EndDoc


It works fine, except for ONE niggling little thing. After re-booting the server, the very FIRST time this code is invoked, despite the fact that I set all these settings to "no" nay "never", no nay "never no more!", it insists on trying to display a dialog. This causes Vista to throw a wobbly, thus:

A little alert box appears in the "task bar" titled "Interactive Services"

When clicked, it tells me:
"A program can't display a message on your desktop"

When I go to view the details it tells me that the offending program is the BullZip program "gui.exe"

Vista kindly provides a link "Why does this happen", and when I check it out, it tells me that

"Some devices and programs that are not fully compatible with Windows do not display their messages on your desktop, but may need your permission or other information to complete a task. To access these messages, click the Show me the Message button.

Only one user at a time can access these messages. If another user is already accessing a message [...] (etc)"


When I clock on "Show me the message" it tells me:

"The program is no longer requesting attention.

The message may have been one that required no action, such as a quick status notification. Windows will notify you if it reappears"


or something of that nature. And indeed, the process has, in the mean time, run to completion without any ill effects.

I notice that when the printer is used interactively rather than through a Service, a little red icon appears amongst the notification icons showing the user that BullZip is currently Printing, and a little balloon pops up telling the user that printing is "complete".

It seems that this is not fully suppressed, despite my best efforts above, and it is still trying to do some of this interactive stuff when it's running as a service.

What am I missing out on here?




It's a minor irritant, as it only happens ONCE after a re-boot of the Server. Any subsequent times, if the services prints something, no new messages appear, and it seems that even that first time nothing untoward happens. But still, it's irritating, and I'd much rather get rid of it if at all possibly.


Many thanks!


Pino