Highlighted
Absent Member.
Absent Member.
374 views

[archive] Calling "winspool.drv" Problem

[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.
0 Likes
4 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Calling "winspool.drv" Problem

I suspect your problem relates to the use of UNSIGNED-INT, try using PIC X(4) COMP-N instead.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Calling "winspool.drv" Problem

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.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Calling "winspool.drv" Problem

Out of curiousity, why do you want to call GetPrinter?
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Calling "winspool.drv" Problem

Thanks for your help that did the trick.

Alex
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.