Skip to main content

[archive] Calling "winspool.drv" Problem

  • December 12, 2007
  • 7 replies
  • 0 views

[Migrated content. Thread originally posted on 11 December 2007]

Does anyone have any experience with calling a non "dll" Version 8. I am trying to retrieve the share printer name calling "winspool.drv" the programs executes, nothing seems to be returned, I know the return status is set to "0" saying its failed, but do not know the reason why ?

Any suggestions ?

The code is below:

A 78 TheBufferPointer VALUE 2048.

A 01 TheBufferedResults
A PIC X(TheBufferPointer) VALUE SPACE.

A 01 THE-SELECTED-PRINTER PIC X(120).

A *This status variable tests the result of the FindFile
A *functions.
A 01 FIND-STATUS UNSIGNED-LONG.
A 88 IS-FALSE VALUE 0.

A 77 ThePrinterHandle UNSIGNED-LONG VALUE 0.
A 77 ThePrinterDefaults UNSIGNED-LONG VALUE 0.
A 77 TheBufferSize UNSIGNED-LONG VALUE 0.
A 77 TheBufferSizeNeeded UNSIGNED-LONG VALUE 0.

A 77 TheFunctionLevel UNSIGNED-LONG VALUE 0.

A *Level or type of structure to store
A 88 LEVEL2 VALUE 02.


E842 SET ENVIRONMENT "CODE_MAPPING" TO "ON".
E842 SET ENVIRONMENT "DLL_CONVENTION" TO "1".

1829 * CALL "winspool.drv" giving find-status.
1829 * CALL "winspool.exe" giving find-status.
1829 CALL "C:\\WINDOWS\\SYSTEM\\winspool.drv" giving find-status.

E842 MOVE CHOSEN-PRINTER TO THE-SELECTED-PRINTER.

E842 INSPECT THE-SELECTED-PRINTER
E842 REPLACING TRAILING SPACES BY LOW-VALUE.

1829 CALL "OpenPrinterA" USING
E842 By Reference THE-SELECTED-PRINTER,
A bY value ThePrinterHandle,
A by value ThePrinterDefaults,
giving find-status.

A SET LEVEL2 TO TRUE.
1829 CALL "GetPrinterA" USING
A by value ThePrinterHandle,
A by value TheFunctionLevel,
A by reference TheBufferedResults(1:TheBufferPointer),
A by value TheBufferSize,
A by value TheBufferSizeNeeded,
A giving find-status.

1829 CALL "ClosePrinter" USING
A By Reference ThePrinterHandle,
A giving find-status.

E842 CANCEL "winspool.drv".

E842 SET ENVIRONMENT "DLL-CONVENTION" TO 0.

7 replies

[Migrated content. Thread originally posted on 11 December 2007]

Does anyone have any experience with calling a non "dll" Version 8. I am trying to retrieve the share printer name calling "winspool.drv" the programs executes, nothing seems to be returned, I know the return status is set to "0" saying its failed, but do not know the reason why ?

Any suggestions ?

The code is below:

A 78 TheBufferPointer VALUE 2048.

A 01 TheBufferedResults
A PIC X(TheBufferPointer) VALUE SPACE.

A 01 THE-SELECTED-PRINTER PIC X(120).

A *This status variable tests the result of the FindFile
A *functions.
A 01 FIND-STATUS UNSIGNED-LONG.
A 88 IS-FALSE VALUE 0.

A 77 ThePrinterHandle UNSIGNED-LONG VALUE 0.
A 77 ThePrinterDefaults UNSIGNED-LONG VALUE 0.
A 77 TheBufferSize UNSIGNED-LONG VALUE 0.
A 77 TheBufferSizeNeeded UNSIGNED-LONG VALUE 0.

A 77 TheFunctionLevel UNSIGNED-LONG VALUE 0.

A *Level or type of structure to store
A 88 LEVEL2 VALUE 02.


E842 SET ENVIRONMENT "CODE_MAPPING" TO "ON".
E842 SET ENVIRONMENT "DLL_CONVENTION" TO "1".

1829 * CALL "winspool.drv" giving find-status.
1829 * CALL "winspool.exe" giving find-status.
1829 CALL "C:\\WINDOWS\\SYSTEM\\winspool.drv" giving find-status.

E842 MOVE CHOSEN-PRINTER TO THE-SELECTED-PRINTER.

E842 INSPECT THE-SELECTED-PRINTER
E842 REPLACING TRAILING SPACES BY LOW-VALUE.

1829 CALL "OpenPrinterA" USING
E842 By Reference THE-SELECTED-PRINTER,
A bY value ThePrinterHandle,
A by value ThePrinterDefaults,
giving find-status.

A SET LEVEL2 TO TRUE.
1829 CALL "GetPrinterA" USING
A by value ThePrinterHandle,
A by value TheFunctionLevel,
A by reference TheBufferedResults(1:TheBufferPointer),
A by value TheBufferSize,
A by value TheBufferSizeNeeded,
A giving find-status.

1829 CALL "ClosePrinter" USING
A By Reference ThePrinterHandle,
A giving find-status.

E842 CANCEL "winspool.drv".

E842 SET ENVIRONMENT "DLL-CONVENTION" TO 0.
I suspect your problem relates to the use of UNSIGNED-INT, try using PIC X(4) COMP-N instead.

[Migrated content. Thread originally posted on 11 December 2007]

Does anyone have any experience with calling a non "dll" Version 8. I am trying to retrieve the share printer name calling "winspool.drv" the programs executes, nothing seems to be returned, I know the return status is set to "0" saying its failed, but do not know the reason why ?

Any suggestions ?

The code is below:

A 78 TheBufferPointer VALUE 2048.

A 01 TheBufferedResults
A PIC X(TheBufferPointer) VALUE SPACE.

A 01 THE-SELECTED-PRINTER PIC X(120).

A *This status variable tests the result of the FindFile
A *functions.
A 01 FIND-STATUS UNSIGNED-LONG.
A 88 IS-FALSE VALUE 0.

A 77 ThePrinterHandle UNSIGNED-LONG VALUE 0.
A 77 ThePrinterDefaults UNSIGNED-LONG VALUE 0.
A 77 TheBufferSize UNSIGNED-LONG VALUE 0.
A 77 TheBufferSizeNeeded UNSIGNED-LONG VALUE 0.

A 77 TheFunctionLevel UNSIGNED-LONG VALUE 0.

A *Level or type of structure to store
A 88 LEVEL2 VALUE 02.


E842 SET ENVIRONMENT "CODE_MAPPING" TO "ON".
E842 SET ENVIRONMENT "DLL_CONVENTION" TO "1".

1829 * CALL "winspool.drv" giving find-status.
1829 * CALL "winspool.exe" giving find-status.
1829 CALL "C:\\WINDOWS\\SYSTEM\\winspool.drv" giving find-status.

E842 MOVE CHOSEN-PRINTER TO THE-SELECTED-PRINTER.

E842 INSPECT THE-SELECTED-PRINTER
E842 REPLACING TRAILING SPACES BY LOW-VALUE.

1829 CALL "OpenPrinterA" USING
E842 By Reference THE-SELECTED-PRINTER,
A bY value ThePrinterHandle,
A by value ThePrinterDefaults,
giving find-status.

A SET LEVEL2 TO TRUE.
1829 CALL "GetPrinterA" USING
A by value ThePrinterHandle,
A by value TheFunctionLevel,
A by reference TheBufferedResults(1:TheBufferPointer),
A by value TheBufferSize,
A by value TheBufferSizeNeeded,
A giving find-status.

1829 CALL "ClosePrinter" USING
A By Reference ThePrinterHandle,
A giving find-status.

E842 CANCEL "winspool.drv".

E842 SET ENVIRONMENT "DLL-CONVENTION" TO 0.
I suspect your problem relates to the use of UNSIGNED-INT, try using PIC X(4) COMP-N instead.

[Migrated content. Thread originally posted on 11 December 2007]

Does anyone have any experience with calling a non "dll" Version 8. I am trying to retrieve the share printer name calling "winspool.drv" the programs executes, nothing seems to be returned, I know the return status is set to "0" saying its failed, but do not know the reason why ?

Any suggestions ?

The code is below:

A 78 TheBufferPointer VALUE 2048.

A 01 TheBufferedResults
A PIC X(TheBufferPointer) VALUE SPACE.

A 01 THE-SELECTED-PRINTER PIC X(120).

A *This status variable tests the result of the FindFile
A *functions.
A 01 FIND-STATUS UNSIGNED-LONG.
A 88 IS-FALSE VALUE 0.

A 77 ThePrinterHandle UNSIGNED-LONG VALUE 0.
A 77 ThePrinterDefaults UNSIGNED-LONG VALUE 0.
A 77 TheBufferSize UNSIGNED-LONG VALUE 0.
A 77 TheBufferSizeNeeded UNSIGNED-LONG VALUE 0.

A 77 TheFunctionLevel UNSIGNED-LONG VALUE 0.

A *Level or type of structure to store
A 88 LEVEL2 VALUE 02.


E842 SET ENVIRONMENT "CODE_MAPPING" TO "ON".
E842 SET ENVIRONMENT "DLL_CONVENTION" TO "1".

1829 * CALL "winspool.drv" giving find-status.
1829 * CALL "winspool.exe" giving find-status.
1829 CALL "C:\\WINDOWS\\SYSTEM\\winspool.drv" giving find-status.

E842 MOVE CHOSEN-PRINTER TO THE-SELECTED-PRINTER.

E842 INSPECT THE-SELECTED-PRINTER
E842 REPLACING TRAILING SPACES BY LOW-VALUE.

1829 CALL "OpenPrinterA" USING
E842 By Reference THE-SELECTED-PRINTER,
A bY value ThePrinterHandle,
A by value ThePrinterDefaults,
giving find-status.

A SET LEVEL2 TO TRUE.
1829 CALL "GetPrinterA" USING
A by value ThePrinterHandle,
A by value TheFunctionLevel,
A by reference TheBufferedResults(1:TheBufferPointer),
A by value TheBufferSize,
A by value TheBufferSizeNeeded,
A giving find-status.

1829 CALL "ClosePrinter" USING
A By Reference ThePrinterHandle,
A giving find-status.

E842 CANCEL "winspool.drv".

E842 SET ENVIRONMENT "DLL-CONVENTION" TO 0.
Haven't tested it, but I figure this should do.

       IDENTIFICATION               DIVISION.
       PROGRAM-ID.                  TEMPLATE.
       ENVIRONMENT                  DIVISION.
       WORKING-STORAGE SECTION.
       78 BufSize                   VALUE 2048.
       01 TheBufferedResults        PIC X(BufSize) VALUE SPACE.
       01 THE-SELECTED-PRINTER      PIC X(120).
       01 FIND-STATUS               PIC X(4) COMP-N.
          88 IS-FALSE               VALUE 0.
       77 ThePrinterHandle          PIC X(4) COMP-N VALUE 0.
       77 ThePrinterDefaults        PIC X(4) COMP-N VALUE 0.
       77 TheBufferSize             PIC X(4) COMP-N VALUE BufSize.
       77 TheBufferSizeNeeded       PIC X(4) COMP-N VALUE 0.
       77 TheFunctionLevel          PIC X(4) COMP-N VALUE 2.
       PROCEDURE DIVISION.
       MAIN-LOGIC.
           CALL    "[EMAIL="winspool.drv@WINAPI"]winspool.drv@WINAPI[/EMAIL]" GIVING FIND-STATUS.
           MOVE    "Microsoft Office Document Image Writer" TO
                   THE-SELECTED-PRINTER.
           INSPECT THE-SELECTED-PRINTER
                   REPLACING TRAILING SPACES BY LOW-VALUE.
           CALL    "OpenPrinterA"   USING
                   BY REFERENCE     THE-SELECTED-PRINTER,
                   BY REFERENCE     ThePrinterHandle
                   BY VALUE         ThePrinterDefaults
                   GIVING           FIND-STATUS.
           CALL    "GetPrinterA"    USING
                   BY VALUE         ThePrinterHandle
                   BY VALUE         TheFunctionLevel
                   BY REFERENCE     TheBufferedResults
                   BY VALUE         TheBufferSize
                   BY REFERENCE     TheBufferSizeNeeded
                   GIVING           FIND-STATUS.
           CALL   "ClosePrinter"    USING
                  BY VALUE          ThePrinterHandle
                  GIVING            FIND-STATUS.
           CANCEL "winspool.drv".
           STOP    RUN.

[Migrated content. Thread originally posted on 11 December 2007]

Does anyone have any experience with calling a non "dll" Version 8. I am trying to retrieve the share printer name calling "winspool.drv" the programs executes, nothing seems to be returned, I know the return status is set to "0" saying its failed, but do not know the reason why ?

Any suggestions ?

The code is below:

A 78 TheBufferPointer VALUE 2048.

A 01 TheBufferedResults
A PIC X(TheBufferPointer) VALUE SPACE.

A 01 THE-SELECTED-PRINTER PIC X(120).

A *This status variable tests the result of the FindFile
A *functions.
A 01 FIND-STATUS UNSIGNED-LONG.
A 88 IS-FALSE VALUE 0.

A 77 ThePrinterHandle UNSIGNED-LONG VALUE 0.
A 77 ThePrinterDefaults UNSIGNED-LONG VALUE 0.
A 77 TheBufferSize UNSIGNED-LONG VALUE 0.
A 77 TheBufferSizeNeeded UNSIGNED-LONG VALUE 0.

A 77 TheFunctionLevel UNSIGNED-LONG VALUE 0.

A *Level or type of structure to store
A 88 LEVEL2 VALUE 02.


E842 SET ENVIRONMENT "CODE_MAPPING" TO "ON".
E842 SET ENVIRONMENT "DLL_CONVENTION" TO "1".

1829 * CALL "winspool.drv" giving find-status.
1829 * CALL "winspool.exe" giving find-status.
1829 CALL "C:\\WINDOWS\\SYSTEM\\winspool.drv" giving find-status.

E842 MOVE CHOSEN-PRINTER TO THE-SELECTED-PRINTER.

E842 INSPECT THE-SELECTED-PRINTER
E842 REPLACING TRAILING SPACES BY LOW-VALUE.

1829 CALL "OpenPrinterA" USING
E842 By Reference THE-SELECTED-PRINTER,
A bY value ThePrinterHandle,
A by value ThePrinterDefaults,
giving find-status.

A SET LEVEL2 TO TRUE.
1829 CALL "GetPrinterA" USING
A by value ThePrinterHandle,
A by value TheFunctionLevel,
A by reference TheBufferedResults(1:TheBufferPointer),
A by value TheBufferSize,
A by value TheBufferSizeNeeded,
A giving find-status.

1829 CALL "ClosePrinter" USING
A By Reference ThePrinterHandle,
A giving find-status.

E842 CANCEL "winspool.drv".

E842 SET ENVIRONMENT "DLL-CONVENTION" TO 0.
Out of curiousity, why do you want to call GetPrinter?

[Migrated content. Thread originally posted on 11 December 2007]

Does anyone have any experience with calling a non "dll" Version 8. I am trying to retrieve the share printer name calling "winspool.drv" the programs executes, nothing seems to be returned, I know the return status is set to "0" saying its failed, but do not know the reason why ?

Any suggestions ?

The code is below:

A 78 TheBufferPointer VALUE 2048.

A 01 TheBufferedResults
A PIC X(TheBufferPointer) VALUE SPACE.

A 01 THE-SELECTED-PRINTER PIC X(120).

A *This status variable tests the result of the FindFile
A *functions.
A 01 FIND-STATUS UNSIGNED-LONG.
A 88 IS-FALSE VALUE 0.

A 77 ThePrinterHandle UNSIGNED-LONG VALUE 0.
A 77 ThePrinterDefaults UNSIGNED-LONG VALUE 0.
A 77 TheBufferSize UNSIGNED-LONG VALUE 0.
A 77 TheBufferSizeNeeded UNSIGNED-LONG VALUE 0.

A 77 TheFunctionLevel UNSIGNED-LONG VALUE 0.

A *Level or type of structure to store
A 88 LEVEL2 VALUE 02.


E842 SET ENVIRONMENT "CODE_MAPPING" TO "ON".
E842 SET ENVIRONMENT "DLL_CONVENTION" TO "1".

1829 * CALL "winspool.drv" giving find-status.
1829 * CALL "winspool.exe" giving find-status.
1829 CALL "C:\\WINDOWS\\SYSTEM\\winspool.drv" giving find-status.

E842 MOVE CHOSEN-PRINTER TO THE-SELECTED-PRINTER.

E842 INSPECT THE-SELECTED-PRINTER
E842 REPLACING TRAILING SPACES BY LOW-VALUE.

1829 CALL "OpenPrinterA" USING
E842 By Reference THE-SELECTED-PRINTER,
A bY value ThePrinterHandle,
A by value ThePrinterDefaults,
giving find-status.

A SET LEVEL2 TO TRUE.
1829 CALL "GetPrinterA" USING
A by value ThePrinterHandle,
A by value TheFunctionLevel,
A by reference TheBufferedResults(1:TheBufferPointer),
A by value TheBufferSize,
A by value TheBufferSizeNeeded,
A giving find-status.

1829 CALL "ClosePrinter" USING
A By Reference ThePrinterHandle,
A giving find-status.

E842 CANCEL "winspool.drv".

E842 SET ENVIRONMENT "DLL-CONVENTION" TO 0.
Out of curiousity, why do you want to call GetPrinter?

[Migrated content. Thread originally posted on 11 December 2007]

Does anyone have any experience with calling a non "dll" Version 8. I am trying to retrieve the share printer name calling "winspool.drv" the programs executes, nothing seems to be returned, I know the return status is set to "0" saying its failed, but do not know the reason why ?

Any suggestions ?

The code is below:

A 78 TheBufferPointer VALUE 2048.

A 01 TheBufferedResults
A PIC X(TheBufferPointer) VALUE SPACE.

A 01 THE-SELECTED-PRINTER PIC X(120).

A *This status variable tests the result of the FindFile
A *functions.
A 01 FIND-STATUS UNSIGNED-LONG.
A 88 IS-FALSE VALUE 0.

A 77 ThePrinterHandle UNSIGNED-LONG VALUE 0.
A 77 ThePrinterDefaults UNSIGNED-LONG VALUE 0.
A 77 TheBufferSize UNSIGNED-LONG VALUE 0.
A 77 TheBufferSizeNeeded UNSIGNED-LONG VALUE 0.

A 77 TheFunctionLevel UNSIGNED-LONG VALUE 0.

A *Level or type of structure to store
A 88 LEVEL2 VALUE 02.


E842 SET ENVIRONMENT "CODE_MAPPING" TO "ON".
E842 SET ENVIRONMENT "DLL_CONVENTION" TO "1".

1829 * CALL "winspool.drv" giving find-status.
1829 * CALL "winspool.exe" giving find-status.
1829 CALL "C:\\WINDOWS\\SYSTEM\\winspool.drv" giving find-status.

E842 MOVE CHOSEN-PRINTER TO THE-SELECTED-PRINTER.

E842 INSPECT THE-SELECTED-PRINTER
E842 REPLACING TRAILING SPACES BY LOW-VALUE.

1829 CALL "OpenPrinterA" USING
E842 By Reference THE-SELECTED-PRINTER,
A bY value ThePrinterHandle,
A by value ThePrinterDefaults,
giving find-status.

A SET LEVEL2 TO TRUE.
1829 CALL "GetPrinterA" USING
A by value ThePrinterHandle,
A by value TheFunctionLevel,
A by reference TheBufferedResults(1:TheBufferPointer),
A by value TheBufferSize,
A by value TheBufferSizeNeeded,
A giving find-status.

1829 CALL "ClosePrinter" USING
A By Reference ThePrinterHandle,
A giving find-status.

E842 CANCEL "winspool.drv".

E842 SET ENVIRONMENT "DLL-CONVENTION" TO 0.
Thanks for your help that did the trick.

Alex

[Migrated content. Thread originally posted on 11 December 2007]

Does anyone have any experience with calling a non "dll" Version 8. I am trying to retrieve the share printer name calling "winspool.drv" the programs executes, nothing seems to be returned, I know the return status is set to "0" saying its failed, but do not know the reason why ?

Any suggestions ?

The code is below:

A 78 TheBufferPointer VALUE 2048.

A 01 TheBufferedResults
A PIC X(TheBufferPointer) VALUE SPACE.

A 01 THE-SELECTED-PRINTER PIC X(120).

A *This status variable tests the result of the FindFile
A *functions.
A 01 FIND-STATUS UNSIGNED-LONG.
A 88 IS-FALSE VALUE 0.

A 77 ThePrinterHandle UNSIGNED-LONG VALUE 0.
A 77 ThePrinterDefaults UNSIGNED-LONG VALUE 0.
A 77 TheBufferSize UNSIGNED-LONG VALUE 0.
A 77 TheBufferSizeNeeded UNSIGNED-LONG VALUE 0.

A 77 TheFunctionLevel UNSIGNED-LONG VALUE 0.

A *Level or type of structure to store
A 88 LEVEL2 VALUE 02.


E842 SET ENVIRONMENT "CODE_MAPPING" TO "ON".
E842 SET ENVIRONMENT "DLL_CONVENTION" TO "1".

1829 * CALL "winspool.drv" giving find-status.
1829 * CALL "winspool.exe" giving find-status.
1829 CALL "C:\\WINDOWS\\SYSTEM\\winspool.drv" giving find-status.

E842 MOVE CHOSEN-PRINTER TO THE-SELECTED-PRINTER.

E842 INSPECT THE-SELECTED-PRINTER
E842 REPLACING TRAILING SPACES BY LOW-VALUE.

1829 CALL "OpenPrinterA" USING
E842 By Reference THE-SELECTED-PRINTER,
A bY value ThePrinterHandle,
A by value ThePrinterDefaults,
giving find-status.

A SET LEVEL2 TO TRUE.
1829 CALL "GetPrinterA" USING
A by value ThePrinterHandle,
A by value TheFunctionLevel,
A by reference TheBufferedResults(1:TheBufferPointer),
A by value TheBufferSize,
A by value TheBufferSizeNeeded,
A giving find-status.

1829 CALL "ClosePrinter" USING
A By Reference ThePrinterHandle,
A giving find-status.

E842 CANCEL "winspool.drv".

E842 SET ENVIRONMENT "DLL-CONVENTION" TO 0.
Thanks for your help that did the trick.

Alex