This sample code creates a PRDINFO3 structure with dummy parameters. This structure is then used to call SplCreateDevice to establish a print device on a local workstation.
#define INCL_BASE
#define INCL_DOSMEMMGR
#define INCL_SPL
#define INCL_SPLDOSPRINT
#include <os2.h>
#include <stdio.h> /* for printf function */
#include <string.h> /* for strcpy function */
INT main (argc, argv)
INT argc;
CHAR *argv[];
{
ULONG splerr ;
ULONG cbBuf;
ULONG ulLevel ;
PSZ pszComputerName ;
PSZ pszPrintDeviceName ;
PRDINFO3 prd3 ;
if (argc != 2)
{
printf("Syntax: sdcrt DeviceName \n");
DosExit( EXIT_PROCESS , 0 ) ;
}
/* We are going to create a print device on the local workstation. */
pszComputerName = (PSZ)NULL ;
/* Get the name from the command line. */
pszPrintDeviceName = argv[1];
/* Level 3 is valid. We will use level 3. */
ulLevel = 3;
/* Get size of buffer needed for a PRDINFO3 structure. */
cbBuf = sizeof(PRDINFO3);
/* Set up the structure with dummy parameters. */
prd3.pszPrinterName = pszPrintDeviceName;
prd3.pszUserName = NULL;
prd3.pszLogAddr = "LPT1";
prd3.uJobId=0;
prd3.pszComment= "Test comment";
prd3.pszDrivers = "IBMNULL";
prd3.usTimeOut = 777;
/* Make the call. */
splerr = SplCreateDevice(pszComputerName, ulLevel,
&prd3, cbBuf);
/* Print out the results. */
if (splerr == NO_ERROR)
printf("The device was successfully created.");
else
printf("SplCreateDevice Error=%ld, cbNeeded=%ld\n",
splerr, cbBuf) ;
DosExit( EXIT_PROCESS , 0 ) ;
return (splerr);
}