SplDeleteDevice

This function deletes a print device.

Syntax
SplDeleteDevice(pszComputerName, pszPrintDeviceName);

Parameters

 * pszComputerName (PSZ) - input
 * Name of computer where print device is. to be deleted.


 * A NULL string specifies the local workstation.


 * pszPrintDeviceName (PSZ) - input
 * Name of Print Device.

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.
 * NERR_NetNotStarted (2102)
 * The network program is not started.
 * NERR_DestNotFound (2152)
 * The print device cannot be found.
 * NERR_DestInvalidState (2162)
 * This operation cannot be performed on the print device.
 * NERR_InvalidComputer (2351)
 * The computer name is invalid.

Sample
This sample code will delete the print device whose name is entered at the prompt.
 * 1) define INCL_BASE
 * 2) define INCL_DOSMEMMGR
 * 3) define INCL_SPL
 * 4) define INCL_SPLDOSPRINT
 * 5) define INCL_SPLERRORS


 * 1) include 
 * 2) include 

INT main (argc, argv) INT argc; CHAR *argv[]; {  SPLERR splerr= 0L; PSZ   pszComputerName ; PSZ   pszPrintDeviceName ;

/* Check that the parameters were entered at the command line. */  if (argc != 2) {     printf("Syntax:  sddel  PrintDeviceName  \n"); DosExit( EXIT_PROCESS, 0 ) ; }

/* Computer name of NULL indicates the local computer. */  pszComputerName = (PSZ)NULL ;

/* Set the PrintDeviceName to the value entered at the command line. */  pszPrintDeviceName = argv[1];

/* Make the call and print out the return code. */  splerr=SplDeleteDevice(pszComputerName, pszPrintDeviceName); switch (splerr) {     case  NO_ERROR: printf("Print Device %s was deleted.\n",pszPrintDeviceName); break; case NERR_DestNotFound : printf("Destination does not exist.\n"); break; case NERR_DestInvalidState: printf("This operation can't be performed on the print device.\n"); break; case NERR_SpoolerNotLoaded: printf("The Spooler is not running.\n"); break; default: printf("SplDeleteDevice Errorcode = %ld\n",splerr); } /* endswitch */ DosExit( EXIT_PROCESS, 0 ) ; return (splerr) ; }

Call Sequence

 * 1) define INCL_SPL /* Or use INCL_PM, */
 * 2) include 

PSZ      pszComputerName;     /*  Name of computer where print device is. to be deleted. */ PSZ      pszPrintDeviceName;  /*  Name of Print Device. */ SPLERR   rc;                  /*  Return code. */

rc = SplDeleteDevice(pszComputerName, pszPrintDeviceName);

Remarks
If the print device is currently printing a job, SplDeleteDevice fails and returns NERR_DestInvalidState (2162).

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

Related Functions

 * SplCreateDevice
 * SplEnumDevice