Notice how this source uses the GET-KEY-VALUE function to retrieve information about the default printer. There are a couple of other methods to get the same information, see topic GetDefaultPrinter.
Besides using the default printer you can also use a different printer; those other printers can be picked using the EnumPrinters function.
code example by Roland the Pijper, converted to 32-bit by Jurjen
{windows.i} DEFINE VARIABLE windir AS CHARACTER. DEFINE VARIABLE pdocname AS MEMPTR. DEFINE VARIABLE poutbuf AS MEMPTR. DEFINE VARIABLE lpdocinfo AS MEMPTR. DEFINE VARIABLE pfilename AS MEMPTR. DEFINE VARIABLE outsize AS INTEGER NO-UNDO. DEFINE VARIABLE printerhDC AS INTEGER NO-UNDO. DEFINE VARIABLE apistatus AS INTEGER NO-UNDO. DEFINE VARIABLE docname AS CHARACTER NO-UNDO. DEFINE VARIABLE devicebuf AS CHARACTER NO-UNDO. DEFINE VARIABLE driverbuf AS CHARACTER NO-UNDO. DEFINE VARIABLE initbuf AS CHARACTER NO-UNDO. DEFINE VARIABLE outbuf AS CHARACTER NO-UNDO. DEFINE VARIABLE windowsdir AS CHARACTER NO-UNDO. DEFINE VARIABLE winini AS CHARACTER NO-UNDO. DEFINE VARIABLE printerdev AS CHARACTER NO-UNDO. DEFINE VARIABLE FILENAME AS CHARACTER NO-UNDO. DEFINE VARIABLE tekst AS CHARACTER NO-UNDO. /* Get printer info from WIN.INI */ windir = FILL("x", 260). RUN GetWindowsDirectoryA IN hpApi(OUTPUT windir, LENGTH(windir), OUTPUT outsize). ASSIGN windowsdir = SUBSTRING(windir,1,outsize) winini = windowsdir + "\WIN.INI". LOAD winini. USE winini. GET-KEY-VALUE SECTION "windows" KEY "device" VALUE printerdev. UNLOAD winini. IF printerdev = "" THEN DO: RUN Err ("Could not locate printer device!"). RETURN. END. ASSIGN devicebuf = ENTRY(1,printerdev). driverbuf = ENTRY(2,printerdev). outbuf = ENTRY(3,printerdev). docname = "test". /* Setup pointers to the strings needed in the lpdocinfo STRUCT */ SET-SIZE(pdocname) = LENGTH(docname) + 1. PUT-STRING(pdocname,1) = docname. SET-SIZE(poutbuf) = LENGTH(outbuf) + 1. PUT-STRING(poutbuf,1) = outbuf. /* Load up the lpdocinfo STRUCT */ SET-SIZE(lpdocinfo) = 4 /* INTEGER cbSize */ + 4 /* pointer lpszDocName */ + 4. /* pointer lpszOutput */ PUT-LONG(lpdocinfo,1) = 12. /* size of the STRUCT */ PUT-LONG(lpdocinfo,5) = GET-POINTER-VALUE(pdocname). /* pointer to CHARACTER */ PUT-LONG(lpdocinfo,9) = GET-POINTER-VALUE(poutbuf). /* pointer to CHARACTER */ tekst = "bla bla". /* Print it! */ RUN adecomm/_setcurs.p ("WAIT"). RUN CreateDCA (driverbuf, devicebuf, outbuf, 0, OUTPUT printerhDC). RUN StartDocA IN hpApi(INPUT printerhDC, INPUT GET-POINTER-VALUE(lpdocinfo), OUTPUT apistatus). /* is printjob id */ RUN StartPage IN hpApi(INPUT printerhDC, OUTPUT apistatus). RUN TextOutA IN hpApi(printerhDC, 800, 450, tekst, LENGTH(tekst), OUTPUT apistatus). IF apistatus=0 /* 0=FALSE */ THEN MESSAGE "There was an error during TextOut " VIEW-AS ALERT-BOX ERROR. RUN EndPage IN hpApi(printerhDC, OUTPUT apistatus). RUN EndDoc IN hpApi(printerhDC, OUTPUT apistatus). RUN DeleteDC(printerhDC, OUTPUT apistatus). /* Clean Up */ SET-SIZE(lpdocinfo) = 0. SET-SIZE(pdocname) = 0. SET-SIZE(poutbuf) = 0. RUN adecomm/_setcurs.p ("").