Jump to content

SplEnumDriver: Difference between revisions

From EDM2
Created page with "This function lists printer presentation drivers on the local workstation or on a remote server. == Syntax == SplEnumDriver(pszComputerName, ulLevel, pBuf, cbBuf, pcReturne..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
This function lists printer presentation drivers on the local workstation or on a remote server.  
This function lists printer presentation drivers on the local workstation or on a remote server.
== Syntax ==  
== Syntax ==  
  SplEnumDriver(pszComputerName, ulLevel, pBuf, cbBuf, pcReturned, pcTotal, pcbNeeded, pReserved);
  SplEnumDriver(pszComputerName, ulLevel, pBuf, cbBuf, pcReturned, pcTotal, pcbNeeded, pReserved)


== Parameters ==
== Parameters ==
;pszComputerName (PSZ) - input  
;pszComputerName (PSZ) - input:Name of computer where queues are to be listed.
:Name of computer where queues are to be listed.  
:A NULL string specifies the local workstation.
 
;ulLevel (ULONG) - input:Level of detail.
:A NULL string specifies the local workstation.  
:The level of detail required. This must be 0.
 
;pBuf (PVOID) - output:Buffer.
;ulLevel (ULONG) - input  
:The returned contents in the buffer are:
:Level of detail.  
;ulLevel Buffer Contents:0 An array of PRDRIVINFO structures
 
;cbBuf (ULONG) - input:Size, in bytes, of Buffer.
:The level of detail required. This must be 0.  
:It must be greater than 0.
 
;pcReturned (PULONG) - output:Number of entries returned.
;pBuf (PVOID) - output  
;pcTotal (PULONG) - output:Total number of entries available.
:Buffer.  
;pcbNeeded (PULONG) - output:Size in bytes of available information.
 
:A value of 0 specifies that the size is not known.
:The returned contents in the buffer are:  
;pReserved (PVOID) - output:Reserved value, must be NULL.
 
;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 ==
== 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)  
:;ERROR_MORE_DATA (234):Additional data is available.
::This request is not supported by the network.  
:;NERR_NetNotStarted (2102):The network program is not started.
:;ERROR_BAD_NETPATH (53)  
:;NERR_BufTooSmall (2123):The API return buffer is too small.
::The network path cannot be located.  
:;NERR_InvalidComputer (2351):The computer name is invalid.
:;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 ==
== Sample ==
This sample code will enumerate all the drivers on a local computer.  
This sample code will enumerate all the drivers on a local computer.
<pre>
<pre>
#define INCL_BASE
#define INCL_BASE
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR
Line 142: Line 106:
   return (splerr);
   return (splerr);
}
}
</pre>
</pre>


Line 167: Line 129:


== Related Functions ==
== Related Functions ==
* [[SplCreateDevice]]  
* [[SplCreateDevice]]
* [[SplCreateQueue]]
* [[SplCreateQueue]]
* [[SplSetDevice]]
* [[SplSetDevice]]
* [[SplSetQueue]]
* [[SplSetQueue]]


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

Latest revision as of 12:48, 2 July 2023

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.

#define INCL_BASE
#define INCL_DOSMEMMGR
#define INCL_SPL
#define INCL_SPLDOSPRINT
#define INCL_SPLERRORS

#include <os2.h>
#include <stdio.h>        /* 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

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

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