AddPortEx function

The AddPortEx function is obsolete and is for use only with Windows NT 4.0 and previous versions.

The AddPortEx function creates and configures a port without user intervention.

Syntax


BOOL AddPortEx(
  HANDLE hMonitor,
  LPSTR pName,
  DWORD Level,
  LPBYTE lpBuffer,
  LPWSTR lpMonitorName
);

Parameters

hMonitor

Caller supplied monitor instance handle. This is the handle returned by the monitor's InitializePrintMonitor2 function. (This parameter does not exist if the print monitor supports InitializePrintMonitor instead of InitializePrintMonitor2.)

pName

Caller-supplied pointer to a string representing the server name, or NULL if the printer is local.

Level

Caller-supplied value indicating the type of structure pointed to by lpBuffer. Possible values are as follows:

LevellpBuffer

1

PORT_INFO_1

2

PORT_INFO_2

 

lpBuffer

Caller-supplied pointer to a PORT_INFO_1 or PORT_INFO_2 structure. These structures are described in the Microsoft Windows SDK documentation.

lpMonitorName

Caller-supplied pointer to a string representing the name of the monitor. Can be NULL.

Return value

If the operation succeeds, the function should return TRUE. Otherwise it should call SetLastError to set an error code and return FALSE.

Remarks

The AddPortEx function can be optionally provided by a port monitor server DLL. If provided, its address must be placed in the server DLL's MONITOR2 structure.

If an application calls the print spooler's AddPortEx function, the spooler in turn calls the server DLL's AddPortEx function.

The AddPortEx function allows the spooler to add a port by directly communicating with the port monitor server DLL, bypassing the port monitor UI DLL. The server DLL's function should add and configure a port but, because it executes on the print server, it cannot display a user interface.

If the Level argument is invalid, the function should call SetLastError with an error code of ERROR_INVALID_LEVEL.

The function should call the spooler's EnumPorts function to verify that the port name specified in the structure pointed to by lpBuffer has not already been used by this or another monitor. If the port name is available, the function should add the port without user intervention and write the port name in the registry under the Ports key.

Requirements

Header

Winsplp.h (include Winsplp.h)

See also

InitializePrintMonitor2
MONITOR2

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft