A port monitor server DLL's XcvDataPort function receives information from, and returns information to, the port monitor's UI DLL.
DWORD
XcvDataPort(
HANDLE hXcv,
LPCWSTR pszDataName,
PBYTE pInputData,
DWORD cbInputData,
PBYTE pOutputData,
DWORD cbOutputData,
PDWORD pcbOutputNeeded
);
If the operation succeeds, this function should return ERROR_SUCCESS. Otherwise, it should return an ERROR_-prefixed Win32 error code. The print monitor UI DLL receives this value in the pdwStatus location specified for XcvData.
Declared in winsplp.h. Include winsplp.h.
Port monitor server DLLs are required to define an XcvDataPort function so they can receive information from, and return information to, port monitor UI DLLs. The function's address must be included in a MONITOR2 structure.
The XcvDataPort function is called by the spooler's XcvData function. The function parameters for XcvDataPort and XcvData are almost identical. (XcvData has an additional parameter, pdwStatus, that is not present in XcvDataPort.)
The string pointed to by pszDataName specifies the operation to be performed. The function must recognize the following data name strings:
| Data Name String | Operation |
|---|---|
| L"AddPort" | All information needed for adding a port has been sent. The function should perform operations necessary to add the specified port, including writing the port name in the registry under the Ports key.
The pInputData parameter points to a NULL-terminated port name string. If the function returns ERROR_SUCCESS, the spooler marks the port as added. This string is specified by the print monitor UI DLL, from within its AddPortUI function. |
| L"DeletePort" | All information needed for deleting a port has been sent. The function should perform operations necessary to delete the specified port, including removing the port name from the registry's Ports key.
The pInputData parameter points to a NULL-terminated port name string. If the function returns ERROR_SUCCESS, the spooler marks the port as deleted. This string is specified by the print monitor UI DLL, from within its DeletePortUI function. |
| L"MonitorUI" | The function should use pOutputData to return the name of the associated port monitor UI DLL.
This string is specified by the print spooler, when an application calls the Platform SDK AddPort function. |
Typically, the function is written to recognize additional, customized strings that are sent by the UI DLL from within its AddPortUI, ConfigurePortUI, and DeletePortUI functions. These strings might represent commands that request current configuration values from the server DLL, or that deliver new values. For example, your XcvDataPort function might recognize the string "GetTransmissionRetryTimeout", which your UI DLL could send to your server DLL to request the currently stored transmission retry time-out value. Or, you might define a set of strings that must be sent before "AddPort" or "DeletePort" is sent, where the strings are used to supply information identifying the port to add or delete.
For a given pszDataName string and input buffer, XcvDataPort might first be called with a cbOutputData value of zero. The function should return a required buffer size in pcbOutputNeeded, along with a return value of ERROR_INSUFFICIENT_BUFFER. The caller can use the value received in pcbOutputNeeded to allocate an output buffer of adequate size, and can then call XcvDataPort again, this time specifying the allocated buffer size in cbOutputData.
The XcvDataPort function must validate all input arguments. Specifically, the function must:
If you are writing a port monitor that will communicate with TCPMON, see TCPMON Xcv Interface.
XcvOpenPort, XcvData, AddPortUI, ConfigurePortUI, DeletePortUI