We want to show the possible printer tray names and try to use DeviceCapabilities from winspool.drv.
If I enter the debugger and step over the DeviceCapabilities-call it works perfectly - again and again as long as I stay in the program.
If the call is executed without entering the debugger I get a "memory access violation".
Here is the code:
01 WK-WINSPOOLDRVJN PIC X(01).
01 WK-TRAYTABELLE.
02 WK-TRAYSATZ OCCURS MAX-PAPER-TRAYS.
03 WK-TRAYNAME PIC X(24).
01 WINSPOOL-PRINTER PIC X(80).
01 WINSPOOL-PORT PIC X(80).
01 WINSPOOL-FC PIC 9(4) COMP-5.
=================================================================
MOVE "J" TO WK-WINSPOOLDRVJN.
CALL "c:\\Windows\\System32\\winspool.drv"
ON EXCEPTION
MOVE "N" TO WK-WINSPOOLDRVJN
GO TO PCPDRU10MEDIA-WINPRINT
END-CALL.
MOVE WRAL50-COMBOZEILE TO WINSPOOL-PRINTER.
INSPECT WINSPOOL-PRINTER REPLACING TRAILING SPACES
BY X"00".
MOVE WINPRINT-PORT TO WINSPOOL-PORT.
INSPECT WINSPOOL-PORT REPLACING TRAILING SPACES
BY X"00".
MOVE SPACE TO WK-TRAYTABELLE.
MOVE 12 TO WINSPOOL-FC.
CALL "DeviceCapabilitiesA" USING
BY REFERENCE WINSPOOL-PRINTER
BY REFERENCE WINSPOOL-PORT
BY VALUE WINSPOOL-FC
BY REFERENCE WK-TRAYTABELLE
ON EXCEPTION
MOVE "N" TO WK-WINSPOOLDRVJN
GO TO PCPDRU10MEDIA-WINPRINT
END-CALL.
IF WK-TRAYTABELLE = SPACE
MOVE "N" TO WK-WINSPOOLDRVJN.
Do you see my error or do you have a tip for me ?
Thanks in advance for your support.
Andreas



