Printer Device Driver Name API

andrew_knapp

New Member
Hello,

Can anyone tell me how to get hold of the printer device driver name. We are trying to reosolve a problem with using text printers through Windows. We use the Generic Text print driver but it occasionally interferes with the output. If we can find out that the printer they are trying to print to is using the Generic Text print driver, we could then print directly to the port name instead of through Windows.

Does anyone have any suggestions?

Thanks
 

m1_ru

New Member
One of possible ways to print directly to
text printers (we use it in our system):

1. Generate the report - write all information to
temporary file. Be sure that it will have unique file-name.
Strandard progress programm
adecomm/_tmpfile.p can be used.

2. Execute external commands
copy /b temp_report_file.txt prn
del temp_report_file.txt
 

grobcj

New Member
EnumPrinter Program

FUNCTION GetStrFromPtrA RETURNS CHARACTER (lpszA AS INTEGER) FORWARD.
DEF VAR PrinterEnum AS MEMPTR.
DEF VAR PrinterEnum1 AS MEMPTR.
DEF VAR Needed AS INT.
DEF VAR Returned AS INT.
DEF VAR retorno AS INT.
DEF VAR c AS INT.
DEF VAR tmp1 AS MEMPTR.
DEF VAR clave AS INT INITIAL 6.
SET-SIZE(PrinterEnum) = 3076.
SET-SIZE(tmp1) = 3076.
RUN EnumPrintersA(clave,"",2,INPUT-OUTPUT PrinterEnum,0,OUTPUT Needed,OUTPUT Returned,OUTPUT retorno).
IF Needed > 0 THEN
DO:
SET-SIZE(PrinterEnum1) = Needed.
RUN EnumPrintersA(clave,"",2,INPUT-OUTPUT PrinterEnum1,Needed,OUTPUT Needed,OUTPUT Returned,OUTPUT retorno).
REPEAT c = 0 TO Returned - 1:
MESSAGE GetStrFromPtrA(GET-LONG(PrinterEnum1,1 + (c * 20))) + "\" + GetStrFromPtrA(GET-LONG(PrinterEnum1,9 + (c * 20))) SKIP
GetStrFromPtrA(GET-LONG(PrinterEnum1,5 + (c * 20)))
VIEW-AS ALERT-BOX.
END.
END.
FUNCTION GetStrFromPtrA RETURNS CHARACTER (lpszA AS INTEGER):
DEF VAR tmp AS INTEGER.
RUN lstrlenA(lpszA,OUTPUT tmp).
PUT-STRING(tmp1,1) = "".
RUN lstrcpyA(tmp1,lpszA,OUTPUT tmp1).
RETURN GET-STRING(tmp1,1,tmp).
END.
PROCEDURE EnumPrintersA EXTERNAL "winspool.drv" :
DEFINE INPUT PARAMETER flags As Long.
DEFINE INPUT PARAMETER NAME As CHAR.
DEFINE INPUT PARAMETER Level As Long.
DEFINE INPUT-OUTPUT PARAMETER pPrinterEnum As MEMPTR.
DEFINE INPUT PARAMETER cdBuf As Long.
DEFINE OUTPUT PARAMETER pcbNeeded As Long.
DEFINE OUTPUT PARAMETER pcReturned As Long.
DEFINE RETURN PARAMETER hnd AS LONG.
END.
PROCEDURE lstrcpyA EXTERNAL "kernel32.dll":
DEFINE INPUT PARAMETER RetVal As MEMPTR.
DEFINE INPUT PARAMETER Ptr As LONG.
DEFINE RETURN PARAMETER hnd AS MEMPTR.
END.
PROCEDURE lstrlenA EXTERNAL "kernel32.dll":
DEFINE INPUT PARAMETER Ptr As LONG.
DEFINE RETURN PARAMETER hnd AS LONG.
END.
 
Top