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

getprinter (winspool)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport("winspool.drv", SetLastError=true)]
public static extern bool GetPrinter(IntPtr hPrinter, Int32 dwLevel, IntPtr pPrinter, Int32 dwBuf, out Int32 dwNeeded);

[DllImport("winspool.drv", SetLastError=true)]
public static extern bool GetPrinter(IntPtr hPrinter, uint dwLevel, IntPtr pPrinter, uint dwBuf, ref uint dwNeeded);

VB Signature:

Declare Function GetPrinter Lib "winspool.drv" (TODO) As TODO

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

            IntPtr pHandle;
            PRINTER_DEFAULTS defaults = new PRINTER_DEFAULTS();
            OpenPrinter(PrinterName, out pHandle, defaults);
            uint cbNeeded = 0;

            bool bRet = GetPrinter(pHandle, 2, IntPtr.Zero, 0, ref cbNeeded);
            if (cbNeeded > 0)
            {
                IntPtr pAddr = Marshal.AllocHGlobal((int)cbNeeded);
                bRet = GetPrinter(pHandle, 2, pAddr, cbNeeded, ref cbNeeded);
                if (bRet)
                {
                    PRINTER_INFO_2 Info2 = new PRINTER_INFO_2();
                    Info2 = (PRINTER_INFO_2)Marshal.PtrToStructure(pAddr, typeof(PRINTER_INFO_2));

// Now use the info from Info2 structure etc

                }
                Marshal.FreeHGlobal(pAddr);

            }

            ClosePrinter(pHandle);

Alternative Managed API:

Do you know one? Please contribute it!

Documentation
GetPrinter 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
Find References
Show Printable Version
Revisions