SplCreatePort
Appearance
This function is called to create a printer port. The printer port can be a virtual port.
- Note
- There is currently no support for using this API to remotely add a printer port.
Syntax
SplCreatePort(pszComputerName, pszPortName, pszPortDriver, ulVersion, pBuf, cbBuf);
Parameters
- pszComputerName (PSZ) - input
- Name of computer where port is to be installed.
- A NULL string is used for installing a port on the local machine. This parameter currently must be NULL.
- pszPortName (PSZ) - input
- Name of printer port to install.
- This port, virtual or regular, must not already exist. Following is an example of a port name:
LPT5
- pszPortDriver (PSZ) - input
- Name of the port driver assigned to this port.
- If not NULL, this field must specify an installed port driver; it is case-sensitive. Following is an example of a port driver:
PARALLEL
- ulVersion (ULONG) - input
- Version of port to create.
- Values are as follows:
- SPLPORT_VERSION_REGULAR - 0
- Creates normal printer port that can be connected to a print queue. This port will remain after a reboot.
- SPLPORT_VERSION_VIRTUAL - 1
- Creates a virtual printer port that can only be used for querying and setting. This port exists only until the spooler is disabled or the machine is rebooted.
- pBuf (PVOID) - input
- Port-driver-specific buffer.
- If SPLPORT_VERSION_VIRTUAL is set, this is a port-driver-specific buffer that contains information necessary for the port driver to set up a virtual connection to the printer. There cannot be any imbedded pointers in this buffer. This buffer wil be passed to the port driver with the BIDI_ADD_VIRTUAL_PORT command.
- cbBuf (ULONG) - input
- Length of the data in pBuf, in bytes.
Returns
- rc (ULONG) - returns
- Return codes.
- 0 Success
- ERROR_DEVICE_IN_USE(99)
- Port name is already defined.
- ERROR_FILE_NOT_FOUND(2)
- Port driver name is not valid.
- ERROR_INVALID_LEVEL(124)
- ulVersion is not 0 or 1.
- ERROR_INVALID_PARAMETER(87)
- An invalid buffer was given.
- ERROR_NOT_ENOUGH_MEMORY(8)
- Not enough memory to satisfy request.
- ERROR_NOT_SUPPORTED(50)
- pszComputerName is not supported, or the port driver does not support the virtual port.
- PMERR_SPL_SPOOLER_NOT_INSTALLED(0x4009)
- Spooler not enabled; virtual ports require spooler to be enabled.
Sample
#define INCL_SPL #define INCL_SPLBIDI #include <os2.h> PSZ pszComputerName; /* Name of computer where port is to be installed. */ PSZ pszPortName; /* Name of printer port to install. */ PSZ pszPortDriver; /* Name of the port driver assigned to this port. */ ULONG ulVersion; /* Version of port to create. */ PVOID pBuf; /* Port-driver-specific buffer. */ ULONG cbBuf; /* Length of the data in pBuf, in bytes. */ ULONG rc; /* Return codes. */ rc = SplCreatePort(pszComputerName, pszPortName, pszPortDriver, ulVersion, pBuf, cbBuf);