This sample code first gets a device name from the command line. It then prompts the user for a parameter number and a value associated with it.
#define INCL_BASE #define INCL_DOSMEMMGR #define INCL_SPL #define INCL_SPLDOSPRINT #define INCL_SPLERRORS #include <os2.h> #include <stdio.h> /* for printf function */ #include <string.h> /* for strlen function */ #include <stdlib.h> /* for atoi function */ INT main (argc, argv) INT argc; CHAR *argv[]; { CHAR bufValue[2]={0}; CHAR bufInput[128]={0}; ULONG splerr ; ULONG cbBuf ; ULONG ulParmNum ; USHORT usParm; PSZ pszComputerName ; PSZ pszPrintDeviceName ; PVOID pBuf; if (argc != 2) { printf("Syntax: sdset DeviceName \n"); DosExit( EXIT_PROCESS , 0 ) ; } pszComputerName = (PSZ)NULL ; /* Set the print device name to the value from the command line. */ pszPrintDeviceName = argv[1]; /* Get the parameter and the value. Store them in buffers. */ printf("Enter Parameter number to be modified\n"); gets(&bufValue[0]); printf("Enter new parameter value \n"); gets(&bufInput[0]); /* Convert the input parmnum to a ULONG. */ ulParmNum = atoi(&bufValue[0]); switch (ulParmNum) { case 10: /* Determine the size of the buffer. */ cbBuf = sizeof(PUSHORT); /* Convert the input parameter to a USHORT. */ usParm =(USHORT)atoi(&bufInput[0]); /* Point the buffer to the value. */ pBuf = &usParm; break; case 3: case 7: case 8: /* Determine the size of the buffer. */ cbBuf = strlen(&bufInput[0])+1; /* Point the buffer to the value. */ pBuf = (PSZ)&bufInput; break; default: printf("Invalid number\n"); DosExit( EXIT_PROCESS , 0 ) ; break; } /* Make the call. */ splerr = SplSetDevice(pszComputerName,pszPrintDeviceName,3L, pBuf,cbBuf,ulParmNum) ; /* Print out the result. */ printf("SplSetDevice Err= %ld, Parameter= %d, cbBuf= %ld ,ulParmNum= %ld\n", splerr, usParm, cbBuf, ulParmNum); DosExit( EXIT_PROCESS , 0 ) ; return (splerr); }