PC_PRINTER_SET_DEFAULT

プリンターを開く前に、プロセス全体のデフォルト プリンターを設定します。
制約事項: このルーチンは現在、UNIX プラットフォームではサポートされていません。

構文:

call "PC_PRINTER_SET_DEFAULT" using by value default-option
                              by reference   default-struct
                              returning      status-code

パラメーター

default-option
呼び出しプロトタイプ (「説明の読み方」を参照):cblt-x4-comp5
PIC:pic x(4) comp-5
default-struct
cblt-printer-default として定義されている集団 (以下を含む)
01 cblt-printer-default                typedef.
  03 cblte-pd-printer-name.
    05 cblte-pd-printer-name-length    cblt-x2-comp5.	*> pic x(2) comp-5.
    05 cblte-pd-printer-name           cblt-x1.       *> Occurs depending on
                                                      *> cblte-pd-printer-name-length.
                                                      *> pic x (printer name length)
  03 cblte-pd-printer-browse REDEFINES cblte-pd-printer-name.
    05 cblte-pd-printer-browse-hwnd    cblt-HWND.     *> pic x(4) comp-5.
    05 cblte-pd-printer-browse-namelen cblt-x2-comp5. *> pic x(2) comp-5.
    05 cblte-pd-reserved               cblt-x2-comp5. *> pic x(2) comp-5.
    05 cblte-pd-printer-browse-name    cblt-x1.       *> Occurs depending on
                                                      *> cblte-pd-printer-browse-namelen.
                                                      *> pic x (printer name length)
status-code
説明の読み方」を参照。

入力パラメーター:

default-option
デフォルトのオプションを次のように指定します。
1 使用するデフォルトのプリンターを設定
2 デフォルトのプリンターをブラウズ
default-option が 1 に設定されている場合
printer-name-length
printer-name の長さ
printer-name
プリンターの名前
default-option が 2 に設定されている場合
browser-hwnd
プリンター ブラウザーのハンドル

出力パラメーター:

default-option が 2 に設定されている場合
printer-name-length
printer-name の長さ
printer-name
プリンターの名前
予約済み
予約済み
status-code
プリンター処理ルーチンの戻りコード

説明:

default-option を 2 に設定した場合、この関数では、ユーザーが選択したプリンターが返されますが、そのプリンターがデフォルトのプリンターとして設定されることはありません。

プリンター名は UNC 形式 (つまり、ネットワーク上に表示されるデバイスのフル ネーム) で入力する必要があります。

例:

例 1:

次の例は、PC_PRINTER_SET_DEFAULT を使用してデフォルトのプリンターを設定する方法を示しています。

 working-storage section.
 01 MyDocumentInfo.
   03 filename.
     05 len              pic x(2) comp-5.
     05 body             pic x(128).
   03 document.
     05 len              pic x(2) comp-5.
     05 body             pic x(128).
   03 document-flags     pic x(4) comp-5.
   03 window-hwnd        pic x(4) comp-5.
 01 Printer-RetCode pic  9(4) comp-5.

 78 USE-OPEN-DIALOG      value 1.
 78 USE-FONT-DIALOG      value 2.
 78 USE-FORCE-PORTRAIT   value 4.
 78 USE-FORCE-LANDSCAPE  value 8.
 78 USE-PROGRESS-DIALOG  value 16.

 01 default-info.
   03 option             pic x(4) comp-5.
   03 ourprinter.
     05 len              pic x(2) comp-5.
     05 body             pic x(128).

 78 SET-DEFAULT-PRINTER  value h"0001".
 procedure division.

     move "My Color PS" 
       to body of ourprinter of default-info
     move 11 to len of ourprinter of default-info
     move SET-DEFAULT-PRINTER to option of default-info

     call "PC_PRINTER_SET_DEFAULT" using 
                     by value option of default-info,
                     by reference ourprinter of default-info
           returning Printer-RetCode
     end-call

     if Printer-RetCode not equal zero
         display "Unable to setup a default printer"
         display " + Retcode = " Printer-RetCode
         stop run
     end-if

     move "c:\config.sys" to body of filename
     move 13 to len of filename
 
     move "My Config.sys" to body of document
     move 13 to len of document

     move USE-PROGRESS-DIALOG to document-flags
     move zero to window-hwnd

     call "PC_PRINT_FILE" using by reference filename
                                by reference document
                                by value document-flags
                                by value window-hwnd
                                returning Printer-RetCode
     end-call

     if Printer-RetCode not equal zero
         display "PC_PRINT_FILE failed.. " Printer-RetCode
     else
         display "PC_PRINT_FILE: OK"
     end-if
     .

例 2:

次の例は、PC_PRINTER_SET_DEFAULT を使用してプリンターをブラウズする方法を示しています。

 working-storage section.
 01 MyDocumentInfo.
   03 filename.
     05 len                 pic x(2) comp-5.
     05 body                pic x(128).
   03 document.
     05 len                 pic x(2) comp-5.
     05 body                pic x(128).
   03 document-flags        pic x(4) comp-5.
   03 window-handle         pic x(4) comp-5.

 01 MyDefaultPrinter.
   03 hwnd                  pic x(4) comp-5.
   03 len                   pic x(2) comp-5.
   03 reserved              pic x(2) comp-5.
   03 body                  pic x(128).

 01 Printer-RetCode         pic 9(4) comp-5.

 78 USE-OPEN-DIALOG         value 1.
 78 USE-FONT-DIALOG         value 2.
 78 USE-FORCE-PORTRAIT      value 4.
 78 USE-FORCE-LANDSCAPE     value 8.
 78 USE-PROGRESS-DIALOG     value 16.

 01 default-info.
   03 option                pic x(4) comp-5.
   03 ourprinter.
     05 len                 pic x(2) comp-5.
     05 body                pic x(128).

 78 SET-DEFAULT-PRINTER     value h"0001".
 78 BROWSE-DEFAULT-PRINTER  value h"0002".

 procedure division.
     move BROWSE-DEFAULT-PRINTER to option of default-info
     move 0 to hwnd of MyDefaultPrinter
     move 127 to len of MyDefaultPrinter

     call "PC_PRINTER_SET_DEFAULT" using
                             by value option of default-info
                             by reference MyDefaultPrinter
                   returning Printer-RetCode
     end-call

     if Printer-RetCode not equal zero
         display "Unable to browse for a default printer"
         display " + Retcode = " Printer-RetCode
         stop run
     end-if

     display "Browse Printer : "
         body of MyDefaultPrinter(1:len of MyDefaultPrinter)

     move SET-DEFAULT-PRINTER to option of default-info
     move len of MyDefaultPrinter to len of ourprinter
     move body of MyDefaultPrinter(1:len of MyDefaultPrinter)
         to body of ourprinter

     call "PC_PRINTER_SET_DEFAULT" using
                     by value option of default-info
                     by reference ourprinter of default-info
                     returning Printer-RetCode
     end-call

     if Printer-RetCode not equal zero
         display "Unable to set a default printer"
         display " + Retcode = " Printer-RetCode
         stop run
     end-if

     move "c:\config.sys" to body of filename
     move 13 to len of filename
 
     move "My Config.sys" to body of document
     move 13 to len of document

     move USE-PROGRESS-DIALOG to document-flags
     move zero to window-handle

     call "PC_PRINT_FILE" using by reference filename
                                by reference document
                                by value document-flags
                                by value window-handle
                          returning Printer-RetCode
     end-call

     if Printer-RetCode not equal zero
         display "PC_PRINT_FILE failed.. " Printer-RetCode
     else
         display "PC_PRINT_FILE: OK"
     end-if.