SplEnumDriver

This function lists printer presentation drivers on the local workstation or on a remote server.

Syntax
SplEnumDriver(pszComputerName, ulLevel, pBuf, cbBuf, pcReturned, pcTotal, pcbNeeded, pReserved);

Parameters

 * pszComputerName (PSZ) - input
 * Name of computer where queues are to be listed.


 * A NULL string specifies the local workstation.


 * ulLevel (ULONG) - input
 * Level of detail.


 * The level of detail required. This must be 0.


 * pBuf (PVOID) - output
 * Buffer.


 * The returned contents in the buffer are:


 * ulLevel Buffer Contents
 * 0 An array of PRDRIVINFO structures


 * cbBuf (ULONG) - input
 * Size, in bytes, of Buffer.


 * It must be greater than 0.


 * pcReturned (PULONG) - output
 * Number of entries returned.


 * pcTotal (PULONG) - output
 * Total number of entries available.


 * pcbNeeded (PULONG) - output
 * Size in bytes of available information.


 * A value of 0 specifies that the size is not known.


 * pReserved (PVOID) - output
 * Reserved value, must be NULL.

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.
 * ERROR_MORE_DATA (234)
 * Additional data is available.
 * NERR_NetNotStarted (2102)
 * The network program is not started.
 * NERR_BufTooSmall (2123)
 * The API return buffer is too small.
 * NERR_InvalidComputer (2351)
 * The computer name is invalid.

Sample
This sample code will enumerate all the drivers on a local computer.


 * 1) define INCL_BASE
 * 2) define INCL_DOSMEMMGR
 * 3) define INCL_SPL
 * 4) define INCL_SPLDOSPRINT
 * 5) define INCL_SPLERRORS


 * 1) include 
 * 2) include        /* for printf function   */

INT main {  SPLERR splerr ; ULONG cbBuf ; ULONG cTotal ; ULONG cReturned ; ULONG cbNeeded ; ULONG i ; PSZ   pszComputerName = NULL ; PSZ   pszDriverName ; PBYTE pbuf ;

/* Call the function the first time with zero in cbBuf. The count of bytes */ /* needed for the buffer to hold all the info will be returned in cbNeeded.*/ splerr = SplEnumDriver(pszComputerName, 0L, NULL, 0L,                            &cReturned, &cTotal, &cbNeeded,                             NULL );

/* If the return code is ERROR_MORE_DATA or NERR_BufTooSmall, then all the */ /* parameters were correct; and we can continue. */  if (splerr == ERROR_MORE_DATA || splerr == NERR_BufTooSmall) {     /* Allocate memory for the buffer to hold the returned information. Use */ /* the count of bytes that were returned by our first call. */     if (!DosAllocMem( &pbuf, cbNeeded, PAG_READ|PAG_WRITE|PAG_COMMIT) ) {        /* Set count of bytes to the value returned by our first call. */        cbBuf= cbNeeded ;

/* Now call the function a second time with the correct values, and */ /* the information will be returned in the buffer. */        splerr= SplEnumDriver(pszComputerName, 0L, pbuf, cbBuf,                                 &cReturned ,&cTotal, &cbNeeded,                                 NULL ) ; if (splerr == NO_ERROR) {           /* Set a pointer to point to the beginning of the buffer. */           pszDriverName = (PSZ)pbuf;

/* Print the names that are in the buffer. The count of the number*/ /* of names in pBuf have been returned in cReturned. */           for (i=0;i < cReturned ; i++) {              printf("Driver name - %s\n", pszDriverName) ; /* Increment the pointer to point to the next name. */              pszDriverName += DRIV_NAME_SIZE + DRIV_DEVICENAME_SIZE + 2; }        }         /* Free the memory allocated for the buffer. */        DosFreeMem(pbuf) ; }  }   else {     /* If the first call to the function returned any error code other      */ /* than ERROR_MORE_DATA or NERR_BufTooSmall, we print the following. */     printf("SplEnumDriver error=%ld \n",splerr) ; }  DosExit( EXIT_PROCESS, 0 ) ; return (splerr); }

Call Sequence

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

PSZ      pszComputerName;  /*  Name of computer where queues are to be listed. */ ULONG    ulLevel;          /*  Level of detail. */ PVOID    pBuf;             /*  Buffer. */ ULONG    cbBuf;            /*  Size, in bytes, of Buffer. */ PULONG   pcReturned;       /*  Number of entries returned. */ PULONG   pcTotal;          /*  Total number of entries available. */ PULONG   pcbNeeded;        /*  Size in bytes of available information. */ PVOID    pReserved;        /*  Reserved value, must be NULL. */ SPLERR   rc;               /*  Return code. */

rc = SplEnumDriver(pszComputerName, ulLevel,      pBuf, cbBuf, pcReturned, pcTotal, pcbNeeded,       pReserved);

Related Functions

 * SplCreateDevice
 * SplCreateQueue
 * SplSetDevice
 * SplSetQueue