Jump to content

SplEnumPort: Difference between revisions

From EDM2
Created page with "This function lists printer ports on the local workstation or on a remote server. == Syntax == SplEnumPort(pszComputerName, ulLevel, pBuf, cbBuf, pcReturned, pcTotal, pcbNe..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
This function lists printer ports on the local workstation or on a remote server.  
This function lists printer ports on the local workstation or on a remote server.
== Syntax ==  
 
  SplEnumPort(pszComputerName, ulLevel, pBuf, cbBuf, pcReturned, pcTotal, pcbNeeded, pReserved);
== Syntax ==
  SplEnumPort(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 or 1.
 
;pBuf (PVOID) - output:Buffer.
;ulLevel (ULONG) - input  
:The returned content in the buffer depends on the value specified in ulLevel as follows:
:Level of detail.  
:ulLevel Buffer Contents
 
::0 An array of PRPORTINFO structures
:The level of detail required. This must be 0 or 1.  
::1 An array of PRPORTINFO1 structures
 
;cbBuf (ULONG) - input:Size, in bytes, of Buffer.
;pBuf (PVOID) - output  
;pcReturned (PULONG) - output:Number of entries returned.
:Buffer.  
;pcTotal (PULONG) - output:Total number of entries available.
 
;pcbNeeded (PULONG) - output:Size in bytes of available information.
:The returned content in the buffer depends on the value specified in ulLevel as follows:  
:A value of 0 specifies that the size is not known.
 
;pReserved (PVOID) - output:Reserved.
:ulLevel Buffer Contents  
:This must be NULL.
::0 An array of PRPORTINFO structures  
::1 An array of PRPORTINFO1 structures  
 
;cbBuf (ULONG) - input  
:Size, in bytes, of Buffer.  
 
;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.  
 
:This 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.
:;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.  


: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 ==
== Sample ==
This sample code will print out all the ports an associated information. This is done at level 1, and for the local workstation.  
This sample code will print out all the ports an associated information. This is done at level 1, and for the local workstation.
<pre>
<pre>
#define INCL_DOSMEMMGR
#define INCL_DOSMEMMGR
#define INCL_SPL
#define INCL_SPL
Line 129: Line 96:
   return (splerr);
   return (splerr);
}  /* end main */
}  /* end main */
</pre>
</pre>


Line 154: Line 119:


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


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

Latest revision as of 18:22, 2 July 2023

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

Syntax

SplEnumPort(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 or 1.
pBuf (PVOID) - output
Buffer.
The returned content in the buffer depends on the value specified in ulLevel as follows:
ulLevel Buffer Contents
0 An array of PRPORTINFO structures
1 An array of PRPORTINFO1 structures
cbBuf (ULONG) - input
Size, in bytes, of Buffer.
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.
This 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 print out all the ports an associated information. This is done at level 1, and for the local workstation.

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

#include <os2.h>
#include <stdio.h>

INT main ()
{
   SPLERR splerr ;
   ULONG  cbBuf ;
   ULONG  cTotal;
   ULONG  cReturned ;
   ULONG  cbNeeded ;
   ULONG  ulLevel = 1;
   ULONG  i ;
   PSZ    pszComputerName = NULL;
   PVOID  pbuf ;
   PPRPORTINFO1 pPort1 ;

   splerr = SplEnumPort(pszComputerName, ulLevel, pbuf, 0L, /* cbBuf */
                            &cReturned, &cTotal,
                            &cbNeeded, NULL) ;

   if (splerr == ERROR_MORE_DATA || NERR_BufTooSmall )
   {
      if (!DosAllocMem( &pbuf, cbNeeded,
                        PAG_READ|PAG_WRITE|PAG_COMMIT) )
      {
          cbBuf = cbNeeded ;
          splerr = SplEnumPort(pszComputerName, ulLevel, pbuf, cbBuf,
                                  &cReturned, &cTotal,
                                  &cbNeeded, NULL) ;
          if (splerr == 0L)
          {
             pPort1 = (PPRPORTINFO1)pbuf ;
             printf("Port names: ");
             for (i=0; i < cReturned; i++)
             {
                printf("Port - %s, Driver - %s Path - %s\n              ",
                       pPort1->pszPortName, pPort1->pszPortDriverName,
                       pPort1->pszPortDriverPathName ) ;
                pPort1++ ;
             }
             printf("\n");
          }
          DosFreeMem(pbuf) ;
      }
   }
   else
   {
      printf("SplEnumPort splerr=%ld, \n",splerr) ;
   }
   DosExit( EXIT_PROCESS , 0 ) ;
   return (splerr);
}   /* end main */

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. */
SPLERR    rc;               /*  Return code. */

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

Related Functions