Jump to content

SplSetDevice: Difference between revisions

From EDM2
Created page with "This function modifies the configuration of a print device. == Syntax == SplSetDevice(pszComputerName, pszPrintDeviceName, ulLevel, pBuf, cbBuf, ulParmNum); == Parameter..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
This function modifies the configuration of a print device.  
This function modifies the configuration of a print device.


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


== Parameters ==
== Parameters ==
;pszComputerName (PSZ) - input  
;pszComputerName (PSZ) - input:Name of computer where print device is to be modified.
:Name of computer where print device is to be modified.  
:A NULL string specifies the local workstation.
 
;pszPrintDeviceName (PSZ) - input:Name of Print Device.
:A NULL string specifies the local workstation.  
;ulLevel (ULONG) - input:Level of detail required.
 
:This must be 3.
;pszPrintDeviceName (PSZ) - input  
;pBuf (PVOID) - input:Buffer.
:Name of Print Device.  
: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.
;ulLevel (ULONG) - input  
:It must be grater than 0.
:Level of detail required.  
;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.
:This must be 3.  
: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:
;pBuf (PVOID) - input  
:Parameter Constant (Value)
:Buffer.  
::pszLogAddr PRD_LOGADDR_PARMNUM (3)
 
::pszComment PRD_COMMENT_PARMNUM (7)
: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  
::pszDrivers PRD_DRIVERS_PARMNUM (8)
 
::usTimeOut PRD_TIMEOUT_PARMNUM (10)
;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 ==
== Returns ==
;rc (SPLERR) - returns  
;rc (SPLERR) - returns:Return code.
:Return code.  
::NO_ERROR (0) : No errors occurred.
 
::ERROR_ACCESS_DENIED (5) : Access is denied.
:;NO_ERROR (0)  
::ERROR_NOT_SUPPORTED (50) : This request is not supported by the network.
::No errors occurred.  
::ERROR_BAD_NETPATH (53) : The network path cannot be located.
:;ERROR_ACCESS_DENIED (5)  
::ERROR_INVALID_PARAMETER (87) : An invalid parameter is specified.
::Access is denied.  
::ERROR_INVALID_LEVEL (124) : The level parameter is invalid.
:;ERROR_NOT_SUPPORTED (50)  
::NERR_NetNotStarted (2102) : The network program is not started.
::This request is not supported by the network.  
::NERR_BufTooSmall (2123) : The API return buffer is too small.
:;ERROR_BAD_NETPATH (53)  
::NERR_DestNotFound (2152) : The print device cannot be found.
::The network path cannot be located.  
::NERR_DestInvalidState (2162) : This operation cannot be performed on the print device.
:;ERROR_INVALID_PARAMETER (87)  
::NERR_SpoolNoMemory (2165) : A spooler memory allocation failure occurred.
::An invalid parameter is specified.  
::NERR_DriverNotFound (2166) : The device driver does not exist.
:;ERROR_INVALID_LEVEL (124)  
::NERR_BadDev (2341) : The requested device is invalid.
::The level parameter is invalid.  
::NERR_InvalidComputer (2351) : The computer name 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 ==
== 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.  
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.
<pre>
<pre>
#define INCL_BASE
#define INCL_BASE
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR
Line 162: Line 125:
     return (splerr);
     return (splerr);
}
}
</pre>
</pre>


== Call Sequence ==
== Call Sequence ==
<pre>
<pre>
#define INCL_SPL /* Or use INCL_PM, */
#define INCL_SPL /* Or use INCL_PM, */
#include <os2.h>
#include <os2.h>


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


rc = SplSetDevice(pszComputerName, pszPrintDeviceName,
rc = SplSetDevice(pszComputerName, pszPrintDeviceName,
       ulLevel, pBuf, cbBuf, ulParmNum);
       ulLevel, pBuf, cbBuf, ulParmNum);
</pre>
</pre>


== Remarks ==
== 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.  
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.  
To modify a print device on a remote server requires administrator privilege.


== Related Functions ==
== Related Functions ==
Line 195: Line 153:
* [[SplEnumDriver]]
* [[SplEnumDriver]]
* [[SplEnumPort]]
* [[SplEnumPort]]
* [[SplEnumPrinter]]  
* [[SplEnumPrinter]]
* [[SplQueryDevice]]
* [[SplQueryDevice]]


[[Category:spl]]
[[Category:Spl]]

Latest revision as of 22:25, 7 June 2020

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