Sdílet prostřednictvím


Rozhraní TCPMON Xcv

Tato část popisuje transceive (Xcv) rozhraní pro standardní monitorování portů TCP/IP (TCPMON). This interface, which is implemented using XcvData and XcvDataPort function calls, enables those using it to configure a TCP/IP printer port or to obtain information about a TCP/IP printer port configuration. Rozhraní Xcv popsané v této části je specifické pro porty TCP/IP. Jiná rozhraní Xcv můžou být k dispozici pro jiné typy portů.

To obtain a handle to an Xcv interface for either a local machine or a remote machine, call the OpenPrinter function. Následující příklad kódu ukazuje, jak získat popisovač Xcv na portu:

HANDLE hXcv = INVALID_HANDLE_VALUE;
PRINTER_DEFAULTS Defaults = { NULL, NULL, <Required Access> };

// Handle to a local machine
if (OpenPrinter(",XcvPort <PortName>", &hXcv, &Defaults )
{
 // hXvc contains an Xcv data handle to a local TCPMON port
}

// Handle to a remote machine
if (OpenPrinter("<ServerName>\\,XcvPort <PortName>", &hXcv, &Defaults )
{
 // hXvc contains an Xcv data handle to a TCPMON port on <ServerName>
}

In the code example, ServerName and PortName represent server and port name strings. Po získání popisovače můžete dotazovat informace specifické pro monitorování portů TCPMON nebo můžete změnit konfiguraci portu. Note that the access you require for the port monitor must be specified in the DesiredAccess member of the PRINTER_DEFAULTS structure or pass NULL if no special security is required. For certain calls to the XcvData function, such as when the AddPort and DeletePort commands are specified (see TCPMON Xcv Commands), SERVER_ACCESS_ADMINISTER privilege is required. For details about the OpenPrinter function and the access rights that may be requested in the PRINTER_DEFAULTS structure, see the OpenPrinter function documentation.

Pokud port ještě neexistuje, lze popisovač Xcv získat ze serveru zadáním názvu monitorování. (V případě standardního portu monitorování portů TCP/IP se jedná o standardní port TCP/IP.) Následující příklad kódu ukazuje, jak získat popisovač dat Xcv monitoru portů:

HANDLE hXcv = INVALID_HANDLE_VALUE;
PRINTER_DEFAULTS Defaults = { NULL, NULL, <Required Access> };

// Handle to a local machine
if (OpenPrinter(",XcvMonitor <MonitorName>", &hXcv, &Defaults )
{
 // hXcv contains an Xcv data handle to the monitor <MonitorName>
}

// Handle to a remote machine
if (OpenPrinter("<ServerName>\\,XcvMonitor <MonitorName>", &hXcv, &Defaults )
{
 // hXcv contains an Xcv data handle to the monitor 
 // <MonitorName> on the server <ServerName>
}

In the code example, ServerName and PortName represent server and port name strings. Once you have obtained the Xcv data handle, you can issue instructions and requests to the monitor by calling the XcvData function.

Note that the return value from the XcvData function indicates only whether the data was correctly sent to the port monitor. A return value of TRUE does not indicate that the operation was successful. To determine whether the operation was successful, inspect the value in *pdwStatus. Tyto hodnoty stavu jsou shrnuté v následující tabulce:

Status value Meaning
NO_ERROR Operace byla úspěšná.
ERROR_ACCESS_DENIED Uživatel nemá dostatečná oprávnění. Příkaz vyžaduje oprávnění SERVER_ACCESS_ADMINISTER.
ERROR_INSUFFICIENT_BUFFER Vyžaduje se výstupní vyrovnávací paměť, ale je menší než požadovaná.
ERROR_INVALID_DATA An input buffer is required, but the pointer to it is NULL, or the size of the input buffer is smaller than required.
ERROR_INVALID_HANDLE Popisovač dat Xcv je neplatný.
ERROR_INVALID_LEVEL Vstupní nebo výstupní datová struktura není správná verze.
ERROR_INVALID_PARAMETER An output buffer is required, but it is NULL, or the output required parameter is NULL and the output buffer is too small, or the standard TCP/IP port monitor does not understand the command being issued.