Cobol Foro

Cobol Foro (https://www.cobolforo.es/index.php)
-   PowerCOBOL (ActiveX, v4 - v11) (https://www.cobolforo.es/forumdisplay.php?f=9)
-   -   [Compilador] Error al compilar con Winspool.lib (https://www.cobolforo.es/showthread.php?t=1521)

fastpho 23 de agosto de 2022 20:11

Error al compilar con Winspool.lib
 
Hola..
Estoy tratando de leer la impresora de windows que esta como predeterminada y setear como predeterminada
una impresora de una lista de impresores , y me encuentro con el error de compilacion:

Código COBOL:
  1.    *Error : error LNK2001: unresolved external symbol _SetDefaultPrinterA@4
  2.    *Error : error LNK2001: unresolved external symbol _GetDefaultPrinterA@8
Tengo seteado en propiedades de Script Cobol -> ALPHAL(WORD)

He podido utilizar la funcion EnumPrinters con esta lib , sin problemas para listar las impresoras locales.

Desde ya muchas gracias cualquier aporte.

Saludos...

Kuk 24 de agosto de 2022 00:36

@fastpho, pega el código a ver cómo haces las llamadas

fastpho 24 de agosto de 2022 13:47

Hola @Kuk, estas son las llamadas , me parece que es mas una problema de libreria porque me toma bien otras funciones como OpenPrinterA, StartDocPrinterA ,StartPagePrinterA
EndPagePrinter,EndDocPrinter , ClosePrinter , EnumPrinters

Funcion : GetDefaultPrinter

link : GetDefaultPrinter function (Winspool.h) - Win32 apps | Microsoft Docs
Código COBOL:
  1.  ENVIRONMENT     DIVISION.
  2.  DATA            DIVISION.
  3.  WORKING-STORAGE SECTION.
  4. * C++
  5. * BOOL GetDefaultPrinter(
  6. *  _In_    LPTSTR  pszBuffer,
  7. *  _Inout_ LPDWORD pcchBuffer
  8. * );
  9.  01 pszBuffer                   PIC X(256).
  10.  01 pcchBuffer                  PIC 9(9) COMP-5 VALUE ZEROS.
  11. * Retorno de la funcion GetDefaultPrinter
  12.  01 Rt-Value-GET                PIC 9(4) COMP-5 VALUE ZEROS.  
  13.  PROCEDURE       DIVISION.
  14. *---------------------------------
  15.  GET-IMPRESOR.
  16.       MOVE 256 TO pcchBuffer.
  17.       CALL "GetDefaultPrinterA" WITH STDCALL
  18.             USING BY REFERENCE pszBuffer       *> pszBuffer Nombre del impresor default
  19.                   BY REFERENCE pcchBuffer      *> pcchBuffer Cantidad caracters del nombre
  20.             RETURNING Rt-Value-GET
  21.       END-CALL.
  22.       display "Rt-Value-GET: " , Rt-Value-GET      
Funcion SetDefaultPrinter
link : SetDefaultPrinter function (Winspool.h) - Win32 apps | Microsoft Docs
Código COBOL:
  1.  ENVIRONMENT     DIVISION.
  2.  DATA            DIVISION.
  3.  WORKING-STORAGE SECTION.
  4. * C++
  5. * BOOL SetDefaultPrinter(
  6. *      _In_ LPCTSTR pszPrinter
  7. *     );
  8. * Retorno de la funcion SetDefaultPrinter
  9.  01 Rt-Value-SET                PIC 9(4) COMP-5 VALUE ZEROS.  
  10.  01 PRINTERS-SELECCIONADA       PIC X(150).
  11. *
  12.  PROCEDURE       DIVISION.
  13.  INICIO.
  14. *---------------------------------
  15.  SETEO-IMPRESOR.
  16.           CALL "SetDefaultPrinterA"  WITH STDCALL  
  17.                USING BY REFERENCE    PRINTERS-SELECCIONADA
  18.                RETURNING Rt-Value-SET
  19.           END-CALL.
  20.           display " Rt-Value-SET :  " , Rt-Value-SET
  21. *-------------------------------------------
  22.      
:yoquese:
Saludos ...

Kuk 24 de agosto de 2022 16:00

@fastpho, descargate la winspool.lib desde aquí: Labs/winspool.lib at master · Aekras1a/Labs · GitHub

A mi me ha funcionado.

fastpho 24 de agosto de 2022 16:40

1 Archivos Adjunto(s)
@Kuk, funciona perfecto con esta lib que me pasas.
Muchas gracias por tu tiempo :beber::bien:

Saludos...


La franja horaria es GMT +2. Ahora son las 03:11.

Powered by: vBulletin, Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.