Jump to content

SplSetDevice

From EDM2
Revision as of 19:17, 28 February 2020 by Martini (talk | contribs) (Created page with "This function modifies the configuration of a print device. == Syntax == SplSetDevice(pszComputerName, pszPrintDeviceName, ulLevel, pBuf, cbBuf, ulParmNum); == Parameter...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This function modifies the configuration of a print device.

Syntax

SplSetDevice(pszComputerName, pszPrintDeviceName, ulLevel, pBuf, cbBuf, ulParmNum);

Parameters

pszComputerName (PSZ) - input
Name of computer where print device is to be modified.
A NULL string specifies the local workstation.
pszPrintDeviceName (PSZ) - input
Name of Print Device.
ulLevel (ULONG) - input
Level of detail required.
This must be 3.
pBuf (PVOID) - input
Buffer.
If ulParmNum is 0, this parameter must contain a complete PRJINFO3 structure Otherwise,it must contain a valid new value for the parameter of the PRJINFO3 structure indicated in ulParmNum
cbBuf (ULONG) - input
Size, in bytes, of Buffer.
It must be grater than 0.
ulParmNum (ULONG) - input
Parameter number.
Specifies either that the entire PRDINFO3 structure is to be modified, or only one specific parameter is to be modified.
If ulParmNum is 0, pBuf must contain a complete PRDINFO3 structure. Otherwise, pBuf must contain a new valid value for the parameter to be modified.
The following are the possible values for this parameter:
Parameter Constant (Value)
pszLogAddr PRD_LOGADDR_PARMNUM (3)
pszComment PRD_COMMENT_PARMNUM (7)
pszDrivers PRD_DRIVERS_PARMNUM (8)
usTimeOut PRD_TIMEOUT_PARMNUM (10)

Returns

rc (SPLERR) - returns
Return code.
NO_ERROR (0)
No errors occurred.
ERROR_ACCESS_DENIED (5)
Access is denied.
ERROR_NOT_SUPPORTED (50)
This request is not supported by the network.
ERROR_BAD_NETPATH (53)
The network path cannot be located.
ERROR_INVALID_PARAMETER (87)
An invalid parameter is specified.
ERROR_INVALID_LEVEL (124)
The level parameter is invalid.
NERR_NetNotStarted (2102)
The network program is not started.
NERR_BufTooSmall (2123)
The API return buffer is too small.
NERR_DestNotFound (2152)
The print device cannot be found.
NERR_DestInvalidState (2162)
This operation cannot be performed on the print device.
NERR_SpoolNoMemory (2165)
A spooler memory allocation failure occurred.
NERR_DriverNotFound (2166)
The device driver does not exist.
NERR_BadDev (2341)
The requested device is invalid.
NERR_InvalidComputer (2351)
The computer name is invalid.


Sample

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);
}


Call Sequence


#define INCL_SPL /* Or use INCL_PM, */
#include <os2.h>

PSZ       pszComputerName;     /*  Name of computer where print device is to be modified. */
PSZ       pszPrintDeviceName;  /*  Name of Print Device. */
ULONG     ulLevel;             /*  Level of detail required. */
PVOID     pBuf;                /*  Buffer. */
ULONG     cbBuf;               /*  Size, in bytes, of Buffer. */
ULONG     ulParmNum;           /*  Parameter number. */
SPLERR    rc;                  /*  Return code. */

rc = SplSetDevice(pszComputerName, pszPrintDeviceName,
       ulLevel, pBuf, cbBuf, ulParmNum);


Remarks

This function allows modification of a print device and its connection to a logical address. To disconnect a print device from a port, use ulLevel=3, ulParmNum=3, and pBuf is a NULL string.

To modify a print device on a remote server requires administrator privilege.

Related Functions