Printing Issue Via IE API

Posted by ruan007 on 19-Jul-2010 21:16

Hi Guys

Our application has a procedure using the following code to do file printing. Before we call this procedure, we output the file to html format. This routine has been working for years. But lately, our main application hangs when our users try to print the document. It doesn't happen all the time though, once it happens, we have to kill and restart the entire application and the printing works again.

I have checked that there is no software changed in terms of IE version, it's always IE 6. What I did realise is that the iexplorer.exe process stays alive and memory usage grows everytime when the printing occurs. I am not sure if that is the case, but even though the memory usage is low, the app still freezes. I did try to add webPrint:QUIT() and RELEASE OBJECT webPrint NO-ERROR two statements after webPrint:ExecWB(), it didn't seem to be useful, iexplorer.exe is still alive and grows in memory.

Any advice?

Thanks

&SCOPED-DEFINE HWND_BROADCAST 65535
&SCOPED-DEFINE WM_WININICHANGE 26

DEF VAR webPrint    AS COM-HANDLE       NO-UNDO.
DEF VAR printPrompt AS INT              NO-UNDO INITIAL 2. /* Use default printer */
DEF VAR appAction   AS INT              NO-UNDO INITIAL 6. /* Print the thing */
DEF VAR spoolFile   AS CHAR             NO-UNDO.

DEF VAR winConParam AS CHAR             NO-UNDO.
DEF VAR iReturn     AS INT              NO-UNDO.

PROCEDURE WriteProfileStringA EXTERNAL "KERNEL32.DLL":
    DEF INPUT PARAMETER lpszSection AS CHAR.
    DEF INPUT PARAMETER lpszKeyName AS CHAR.
    DEF INPUT PARAMETER lpszString AS CHAR.
    DEF RETURN PARAMETER iReturn AS LONG.
END.
PROCEDURE SendMessageA EXTERNAL "USER32.DLL":
    DEF INPUT PARAMETER p1 AS LONG.
    DEF INPUT PARAMETER p2 AS LONG.
    DEF INPUT PARAMETER p3 AS LONG.
    DEF INPUT PARAMETER p4 AS CHAR.
    DEF RETURN PARAMETER result AS LONG.
END.

ASSIGN
  spoolFile   = "c:\temp\docket.html"
  winConParam = "
\\fs-01\toshiba-bw-printer,winspool,Ne04:". /* at run time, this value is retrieved by reading the regitry key value in HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\device*/

        

CREATE "InternetExplorer.Application" webPrint.
/* get the file */
NO-RETURN-VALUE webPrint:Navigate (spoolFile, , , , ).

SESSION:PRINTER-CONTROL-HANDLE = 0.
RUN WriteProfileStringA("windows",
                        "device",
                        winConParam,
                        OUTPUT iReturn).
RUN SendMessageA( {&HWND_BROADCAST},
                  {&WM_WININICHANGE},0,"WINDOWS",
                  OUTPUT iReturn).

NO-RETURN-VALUE webPrint:ExecWB ( appAction, printPrompt, , ). 

All Replies

Posted by ruan007 on 19-Jul-2010 22:27

Hi,

A correction to my previous post. The webPrint:QUIT() call does terminate the iexplorer.exe process if there is no iexplorer process exists in the first place. In our case, we always have a embeded web brower to display intranet content.

Another problem with webPrint:quit() method is that it doesn't send the print job to the printer anymore, probably it terminates the process before the job reaches the printer.

Damn it

This thread is closed