Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 什么是xvport(用于OpenPrinter函数)_C++_Winapi - Fatal编程技术网

C++ 什么是xvport(用于OpenPrinter函数)

C++ 什么是xvport(用于OpenPrinter函数),c++,winapi,C++,Winapi,我使用的是OpenPrinter函数,该函数的第一个参数名为“pPrinterName” 这就是它的MSDN描述: [in]指向以null结尾的字符串的指针,该字符串指定打印机或打印服务器、打印机对象、XcvMonitor或XcvPort的名称。 对于打印机对象,请使用:PrinterName,作业xxxx。对于XcvMonitor,请使用:ServerName、XcvMonitor MonitorName对于xvport,使用:ServerName,xvport PortName 显然我对粗体

我使用的是OpenPrinter函数,该函数的第一个参数名为“pPrinterName” 这就是它的MSDN描述:

[in]指向以null结尾的字符串的指针,该字符串指定打印机或打印服务器、打印机对象、XcvMonitor或XcvPort的名称。 对于打印机对象,请使用:PrinterName,作业xxxx。对于XcvMonitor,请使用:ServerName、XcvMonitor MonitorName对于xvport,使用:ServerName,xvport PortName

显然我对粗体部分感兴趣。xvport到底是什么?我知道这似乎是一个懒惰的人的问题,但我真的找不到关于这个概念的信息。如果我想在端口ABC上打开打印机,我应该写:
\\mysrevr,xvport ABC”?

非常接近,只需添加一个反斜杠:

[DllImport("winspool.drv", EntryPoint = "OpenPrinter", SetLastError = true)]
    internal static extern bool OpenPrinter(string pPrinterName, ref IntPtr phPrinter, PRINTER_DEFAULTS pDefault);

[DllImport("winspool.drv", EntryPoint = "ClosePrinter", SetLastError = true)]
    internal static extern int ClosePrinter(IntPtr hPrinter);

public struct OpenPrinterAccessCodes
{
    public const int DELETE = 0x10000; // DELETE - Allowed to delete printers
    public const int READ_CONTROL = 0x20000; // READ_CONTROL - Allowed to read printer information
    public const int WRITE_DAC = 0x40000; // WRITE_DAC - Allowed to write device access control info
    public const int WRITE_OWNER = 0x80000; // WRITE_OWNER - Allowed to change the object owner
    public const int SERVER_ACCESS_ADMINISTER = 0x1;
    public const int SERVER_ACCESS_ENUMERATE = 0x2;
    public const int PRINTER_ACCESS_ADMINISTER = 0x4;
    public const int PRINTER_ACCESS_USE = 0x8;
    public const int STANDARD_RIGHTS_REQUIRED = 0xF0000;
    public const int PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | PRINTER_ACCESS_ADMINISTER | PRINTER_ACCESS_USE);
    public const int SERVER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | SERVER_ACCESS_ADMINISTER | SERVER_ACCESS_ENUMERATE);

    public const int MAX_PORTNAME_LEN = 64;
    public const int MAX_NETWORKNAME_LEN = 49;
    public const int MAX_SNMP_COMMUNITY_STR_LEN = 33;
    public const int MAX_QUEUENAME_LEN = 33;
    public const int MAX_IPADDR_STR_LEN = 16;

    public const int ERROR_INSUFFICIENT_BUFFER = 122;
    public const int ERROR_INVALID_FLAGS = 1004;
}
var def = new PRINTER_DEFAULTS { pDatatype = null, pDevMode = IntPtr.Zero, DesiredAccess = OpenPrinterAccessCodes.SERVER_ACCESS_ADMINISTER };
var hPrinter = IntPtr.Zero;
OpenPrinter(@"\\MyServer\,XcvPort ABC", ref hPrinter, def)
ClosePrinter(hPrinter);

看看这个:这都是类似于“编程”的原型:-)如果没有端口实例,则使用XcvMonitor,否则使用XcvPort。句柄上的所有操作都执行相同的操作。但是XcvPort可能会打开另一个监视器dll。现在我正在研究这个问题。我应该提到,xvport是用来打开打印机端口的,而不是真正的打印机。