NOTICE: Our Community is moving. Get more information.
The native code program can call a managed code program by using COM Interop functionality of .NET. Attached is a Visual Studio Solution that demonstrates how this can be done.The description of this example is as follows:VCPRINTRAWThis example program demonstrates how a file containing Printer Control codes (PCL) can be sent to a printer as RAW data so that the esc sequences will not be stripped out by the Windows print driver. Starting in Visual COBOL 2.0, two methods of accomplishing this task have been added for managed code .NET programs. The first method is to set the printer_raw_redirection=true tunable in the app.config file.The second method and the one that is demonstrated here is to use a new flag value of 32 when calling the PC_PRINT_FILE library routine.Because this is only available directly to managed code programs, this example shows how a native program can call a managed program using COM Interop so it to can send a file with embedded PCL codes to the printer. This program defines an interface and is registered for COM Interop, see Project-->Properties-->COBOL tab-->Advanced button. It can therefore be called by any COM client program including native COBOL. See project vcrawprintcom in this solution for example of how to call this program from native COBOL. This program is called with three parameters, a printer name, a file name and a status-code to be returned. If the printer name is specifield then the default printer name will be changed to this name before printing. If printer name is blank then a printer selection dialog box will be presented prior to printing. If neither of these options is used then PC_PRINT_FILE will print to the current default printer in Windows. You must run Visual COBOL as Administrator in order to build this solution as this is required in order to register this program as COM.