Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

XcvData (winspool)
 
.
Summary
This allows you to communicate with a print monitor

C# Signature:

[DllImport("winspool.drv", SetLastError=true)]
[DllImport("winspool.dll", SetLastError=true)]
static extern bool XcvData(IntPtr hXcv, [MarshalAs(UnmanagedType.LPWStr)] string pszDataName, IntPtr InputData, uint cbInputData,
              IntPtr OutputData, uint cbOutputData,out uint cbOutputNeeded,out uint dwStatus);

VB Signature:

Declare Function XcvData Lib "winspool.drv" (TODO) As TODO
Declare Function XcvData Lib "winspool.dll" (TODO) As TODO

User-Defined Types:

PRINTER_DEFAULTS

Notes:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Sample Code:

Notes:

None.

     const  uint SERVER_ACCESS_ADMINISTER   = 0x00000001;

Tips & Tricks:

Please add some!

     string szIPAddress="";
     string xcvName = String.Format(",XcvPort {0}", portName);

Sample Code:

     IntPtr buf= Marshal.AllocHGlobal(256);
     IntPtr hXcv = IntPtr.Zero;
     const  uint SERVER_ACCESS_ADMINISTER   = 0x00000001;

     PRINTER_DEFAULTS Defaults = new PRINTER_DEFAULTS();
     Defaults.pDatatype = 0 ;
     Defaults.pDevMode = 0;
     Defaults.DesiredAccess = SERVER_ACCESS_ADMINISTER;
     string szIPAddress="";
     string xcvName = String.Format(",XcvPort {0}", portName);

     // Handle to a local machine
     if (OpenPrinter(xcvName,out hXcv, ref Defaults ))
     {
        uint cbOutputNeeded;
        uint dwStatus;
        // hXvc contains an Xcv data handle to a local TCPMON port
        if (XcvData(hXcv, "IPAddress", IntPtr.Zero, 0, buf, 256, out cbOutputNeeded, out dwStatus))
        {
           szIPAddress= Marshal.PtrToStringAuto(buf);
           Console.Write(szRet);
        }
     IntPtr buf= Marshal.AllocHGlobal(256);
     IntPtr hXcv = IntPtr.Zero;

     }
     PRINTER_DEFAULTS Defaults = new PRINTER_DEFAULTS();
     Defaults.pDatatype = 0 ;
     Defaults.pDevMode = 0;
     Defaults.DesiredAccess = SERVER_ACCESS_ADMINISTER;

     ClosePrinter(hXcv);
     // Handle to a local machine
     if (OpenPrinter(xcvName,out hXcv, ref Defaults ))
     {
        uint cbOutputNeeded;
        uint dwStatus;
        // hXvc contains an Xcv data handle to a local TCPMON port
        if (XcvData(hXcv, cmd, IntPtr.Zero, 0, buf, 256, out cbOutputNeeded, out dwStatus))
        {
           szIPAddress= Marshal.PtrToStringAuto(buf);
           Console.Write(szRet);
        }

     if (buf != IntPtr.Zero)
        Marshal.FreeHGlobal(buf);
     }

     ClosePrinter(hXcv);

Documentation
XcvData on MSDN
Documentation

     if (buf != IntPtr.Zero)
        Marshal.FreeHGlobal(buf);

Documentation
XcvData on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions