SplDeleteDevice
Appearance
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.
#define INCL_BASE #define INCL_DOSMEMMGR #define INCL_SPL #define INCL_SPLDOSPRINT #define INCL_SPLERRORS #include <os2.h> #include <stdio.h> 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
#define INCL_SPL /* Or use INCL_PM, */ #include <os2.h> 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.