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

Search Results for "print" in [All]

mpr

.

        RESOURCETYPE_PRINT,

.

  //      RESOURCETYPE_PRINT      = 2,

.

    Print = 2,

.

        RESOURCETYPE_PRINT,

.

    RESOURCETYPE_PRINT = 0x00000002,

.

    RESOURCETYPE_PRINT = &H2

.

localName is the local name for the network resource (drive or printer)

.

    PRINT   = 0x00000002,

coredll

.

     public short dmPrintQuality;

.

        short dmPrintQuality;

.

    Public Property dmPrintQuality() As Short

.
Summary
Add serial debug prints under Windows CE
.

static extern void NKDbgPrintfW(string str);

.

//Taken from http://www.codeproject.com/csharp/timezoneconversions.asp?print=true

crypt32

.

   printf("Opened the MY system store. \n");

.

   printf( "Could not open the MY system store.\n");

.

  printf("The MY store is duplicated.\n");

.

  printf("Duplication of the MY store failed.\n.");

netapi32

.

    ''' Admin, Accounts, Print, or Server Operator group membership is required to successfully execute NetMessageBufferSend on a remote server.

.

            PrintQueueServer = 0x00000200,

.

            MicrosoftFileAndPrintServer= 0x00004000,

.

            SV_TYPE_PRINTQ_SERVER = 0x00000200,

.

    PrintQueueServer = 0x00000200,

.

    MicrosoftFileAndPrintServer= 0x00004000,

.

            STYPE_PRINTQ = 1,

.

        ' <summary>Printer Share</summary>

.

        Printer = 1

.

            STYPE_PRINTQ = 1,

.

        STYPE_PRINTQ = 1,

.
Summary
The NetUseAdd function establishes a connection between the local computer and a remote server. You can specify a local drive letter or a printer device to connect. If you do not specify a local drive letter or printer device, the function authenticates the client with the server for future connections.

Constants

.

    public static readonly Guid GUID_DEVCLASS_DOT4PRINT = new Guid("{0x49ce6ac8, 0x6f86, 0x11d2, {0xb1, 0xe5, 0x00, 0x80, 0xc7, 0x2e, 0x74, 0xa2}}");

.

    public static readonly Guid GUID_DEVCLASS_PNPPRINTERS = new Guid("{0x4658ee7e, 0xf050, 0x11d1, {0xb6, 0xbd, 0x00, 0xc0, 0x4f, 0xa3, 0x72, 0xa7}}");

.

    public static readonly Guid GUID_DEVCLASS_PRINTER = new Guid("{0x4d36e979, 0xe325, 0x11ce, {0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18}}");

.

    public static readonly Guid GUID_DEVCLASS_PRINTERUPGRADE = new Guid("{0x4d36e97a, 0xe325, 0x11ce, {0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18}}");

18: NERR_
.

        /// <summary> 2150 - The printer does not exist. </summary>

.

        /// <summary> 2151 - The print job does not exist. </summary>

.

        /// <summary> 2152 - The printer destination cannot be found. </summary>

.

        /// <summary> 2153 - The printer destination already exists. </summary>

.

        /// <summary> 2154 - The printer queue already exists. </summary>

.

        /// <summary> 2155 - No more printers can be added. </summary>

.

        /// <summary> 2156 - No more print jobs can be added. </summary>

.

        /// <summary> 2157 - No more printer destinations can be added. </summary>

.

        /// <summary> 2158 - This printer destination is idle and cannot accept control operations. </summary>

.

        /// <summary> 2159 - This printer destination request contains an invalid control function. </summary>

.

        /// <summary> 2160 - The print processor is not responding. </summary>

.

        /// <summary> 2162 - This operation cannot be performed on the print destination in its current state. </summary>

.

        /// <summary> 2163 - This operation cannot be performed on the printer queue in its current state. </summary>

.

        /// <summary> 2164 - This operation cannot be performed on the print job in its current state. </summary>

.

        /// <summary> 2167 - The data type is not supported by the print processor. </summary>

.

        /// <summary> 2168 - The print processor is not installed. </summary>

.

private const int PRINTER_ACCESS_ADMINISTRATOR = 0x4;

.

private const int PRINTER_ACCESS_USE = 0x8;

.

private const int PRINTER_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | PRINTER_ACCESS_ADMINISTRATOR | PRINTER_ACCESS_USE;

.

    public static PropertyKey PKEY_Document_DatePrinted = new PropertyKey( 0xF29F85E0, 0x4FF9, 0x1068, 0xAB, 0x91, 0x08, 0x00, 0x2B, 0x27, 0xB3, 0xD9, 11);

.

const UInt32 RESOURCETYPE_PRINT = 0x00000002;

.

    public const int PO_DELETE      = 0x0013;  // printer is being deleted

.

    public const int PO_RENAME      = 0x0014;  // printer is being renamed

.

    public const int PO_PORTCHANGE  = 0x0020;  // port this printer connected to is being changed

.

        // list of strings.  The first is the printer

.

        // name and the second is the printer port.

.

    // Printer stuff

.

    public const int PRINTACTION_OPEN         = 0;

.

    public const int PRINTACTION_PROPERTIES       = 1;

.

    public const int PRINTACTION_NETINSTALL       = 2;

.

    public const int PRINTACTION_NETINSTALLLINK   = 3;

.

    public const int PRINTACTION_TESTPAGE     = 4;

.

    public const int PRINTACTION_OPENNETPRN       = 5;

.

    public const int PRINTACTION_DOCUMENTDEFAULTS = 6;

.

    public const int PRINTACTION_SERVERPROPERTIES = 7;

.

    public const int PO_DELETE      = 0x0013;  // printer is being deleted

.

    public const int PO_RENAME      = 0x0014;  // printer is being renamed

.

    public const int PO_PORTCHANGE  = 0x0020;  // port this printer connected to is being changed

.

        // list of strings.  The first is the printer

.

        // name and the second is the printer port.

.

    // Printer stuff

.

    public const int PRINTACTION_OPEN         = 0;

.

    public const int PRINTACTION_PROPERTIES       = 1;

.

    public const int PRINTACTION_NETINSTALL       = 2;

.

    public const int PRINTACTION_NETINSTALLLINK   = 3;

.

    public const int PRINTACTION_TESTPAGE     = 4;

.

    public const int PRINTACTION_OPENNETPRN       = 5;

.

    public const int PRINTACTION_DOCUMENTDEFAULTS = 6;

.

    public const int PRINTACTION_SERVERPROPERTIES = 7;

.

        /// The printer is out of paper.

.

        /// The printer queue is full.

.

        public const int ERROR_PRINTQ_FULL = 61;

.

        /// Space to store the file waiting to be printed is not available on the server.

.

        /// Your file waiting to be printed was deleted.

.

        public const int ERROR_PRINT_CANCELLED = 63;

.

        /// The specified printer or disk device has been paused.

.

        /// The specified printer driver is already installed.

.

        public const int ERROR_PRINTER_DRIVER_ALREADY_INSTALLED = 1795;

.

        /// The printer driver is unknown.

.

        public const int ERROR_UNKNOWN_PRINTER_DRIVER = 1797;

.

        /// The print processor is unknown.

.

        public const int ERROR_UNKNOWN_PRINTPROCESSOR = 1798;

.

        /// The printer name is invalid.

.

        public const int ERROR_INVALID_PRINTER_NAME = 1801;

.

        /// The printer already exists.

.

        public const int ERROR_PRINTER_ALREADY_EXISTS = 1802;

.

        /// The printer command is invalid.

.

        public const int ERROR_INVALID_PRINTER_COMMAND = 1803;

.

        /// The specified printer handle is already being waited on

.

        /// The specified printer has been deleted.

.

        public const int ERROR_PRINTER_DELETED = 1905;

.

        /// The state of the printer is invalid.

.

        public const int ERROR_INVALID_PRINTER_STATE = 1906;

.

        /// The printer driver is not compatible with a policy enabled on your computer that blocks NT 4.0 drivers.

.

        public const int ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED = 1936;

.

        /// The specified print monitor is unknown.

.

        public const int ERROR_UNKNOWN_PRINT_MONITOR = 3000;

.

        /// The specified printer driver is currently in use.

.

        public const int ERROR_PRINTER_DRIVER_IN_USE = 3001;

.

        /// A StartDocPrinter call was not issued.

.

        /// The specified print processor has already been installed.

.

        public const int ERROR_PRINT_PROCESSOR_ALREADY_INSTALLED = 3005;

.

        /// The specified print monitor has already been installed.

.

        public const int ERROR_PRINT_MONITOR_ALREADY_INSTALLED = 3006;

.

        /// The specified print monitor does not have the required functions.

.

        public const int ERROR_INVALID_PRINT_MONITOR = 3007;

.

        /// The specified print monitor is currently in use.

.

        public const int ERROR_PRINT_MONITOR_IN_USE = 3008;

.

        /// The requested operation is not allowed when there are jobs queued to the printer.

.

        public const int ERROR_PRINTER_HAS_JOBS_QUEUED = 3009;

.

        /// No printers were found.

.

        public const int ERROR_PRINTER_NOT_FOUND = 3012;

.

        /// The printer driver is known to be unreliable.

.

        public const int ERROR_PRINTER_DRIVER_WARNED = 3013;

.

        /// The printer driver is known to harm the system.

.

        public const int ERROR_PRINTER_DRIVER_BLOCKED = 3014;

.

        /// The string contains a non-printable character.

.

        public const int CRYPT_E_INVALID_PRINTABLE_STRING = (int)(0x80092021 - 0x100000000);

25: WM
.
WM_PRINT 0x317 The WM_PRINT message is sent to a window to request that it draw itself in the specified device context, most commonly in a printer device context.
.
WM_PRINTCLIENT 0x318 The WM_PRINTCLIENT message is sent to a window to request that it draw its client area in the specified device context, most commonly in a printer device context.
.
WM_SPOOLERSTATUS 0x2A The WM_SPOOLERSTATUS message is sent from Print Manager whenever a job is added to or removed from the Print Manager queue.
.

private const UInt32 WM_PRINT          = 0x0317;

.

private const UInt32 WM_PRINTCLIENT        = 0x0318;

.

   WM_PRINT = &H317

.

   WM_PRINTCLIENT = &H318

.

WM_PRINT          equ 317h

.

WM_PRINTCLIENT        equ 318h

printui

.
Summary
PrintUIEntryW is the main entrypoint to the printer configuration functions in the PrintUI.dll.
.

[DllImport("printui.dll", SetLastError = true, CharSet = CharSet.Unicode)]

.

private static extern void PrintUIEntryW(IntPtr hwnd, IntPtr hinst, string lpszCmdLine, int nCmdShow);

.

PrintUIEntry(IntPtr.Zero, IntPtr.Zero, @"/?", 0);

.

Add per machine printer connection (the connection will be propagated to the user upon logon):

.

PrintUIEntry(IntPtr.Zero, IntPtr.Zero, @"/c \\machine /ga /n\\server\queue", 0);

.

Delete per machine printer connection (the connection will be deleted upon user logon):

.

PrintUIEntry(IntPtr.Zero, IntPtr.Zero, @"/c \\machine /gd /n\\server\queue", 0);

.

View default printer's properties

.

PrintDocument printDoc = new PrintDocument();

.

PrintUIEntryW(IntPtr.Zero, IntPtr.Zero, @"/p /n " + "\ " + printDoc.PrinterSettings.PrinterName + "\ ", 0);

.

// "\"" required for printer name with spaces

.
Documentation
[PrintUIEntry] on MSDN
.
Namespace
printui
.
Description
printui.dll
.
Title
printui.dll

urlmon

.

  Debug.Print PtrToString(buffAddr)

ntdll

.

     System.Diagnostics.Debug.Print(

.

        // print results:

.

    //        sample printout:

comdlg32

.

     CF_PRINTERFONTS = 0x00000002,

.

     CF_BOTH = (CF_SCREENFONTS | CF_PRINTERFONTS),

.

private static extern bool PrintDlgEx([In(), Out()] PRINTDLGEX lppd);

.

Private Shared Function PrintDlgEx(<[In](), Out()> ByVal lppd As PRINTDLGEX) As Boolean

.

System.Windows.Forms.PrintDialog

.

Public Class WWPrintDialog

.

    Private m_bAllowPrintToFile As Boolean = False

.

    Private m_sPrinterName As String = String.Empty

.

    Private Shared Function PrintDlgEx(<[In](), Out()> ByVal lppd As PRINTDLGEX) As Boolean

.

        Return InvokePrintDlgEx()

.

    Public Function InvokePrintDlgEx() As DialogResult

.

        Dim _pdex As PRINTDLGEX = New PRINTDLGEX()

.

        Dim _ppr As PRINTPAGERANGE = New PRINTPAGERANGE()

.

        Dim prnsettings As Printing.PrinterSettings = New Printing.PrinterSettings()

.

        _pdex.lpPrintTemplateName = Nothing

.

        _pdex.Flags = PRINTFLAG.PD_NOSELECTION Or PRINTFLAG.PD_NOPAGENUMS

.

        Return IIf(PrintDlgEx(_pdex), DialogResult.OK, DialogResult.Cancel)

.

Public Class PRINTDLGEX

.

    Public lpPrintTemplateName As String

.

Public Class PRINTPAGERANGE

.

Public Class PRINTFLAG

.

    Public Const PD_PRINTTOFILE As Int32 = 32

.

    Public Const PD_PRINTSETUP As Int32 = 64

.

    Public Const PD_ENABLEPRINTHOOK As Int32 = 4096

.

    Public Const PD_ENABLEPRINTTEMPLATE As Int32 = 16384

.

    Public Const PD_ENABLEPRINTTEMPLATEHANDLE As Int32 = 65536

.

    Public Const PD_DISABLEPRINTTOFILE As Int32 = 524288

.

    Public Const PD_HIDEPRINTTOFILE As Int32 = 1048576

.
Documentation
[PrintDlgEx] on MSDN
.

private static extern bool PrintDlgEx([In(), Out()] PRINTDLGEX lppd);

.

Private Shared Function PrintDlgEx(<[In](), Out()> ByVal lppd As PRINTDLGEX) As Boolean

.

System.Windows.Forms.PrintDialog

.

Public Class WWPrintDialog

.

    Private m_bAllowPrintToFile As Boolean = False

.

    Private m_sPrinterName As String = String.Empty

.

    Private Shared Function PrintDlgEx(<[In](), Out()> ByVal lppd As PRINTDLGEX) As Boolean

.

        Return InvokePrintDlgEx()

.

    Public Function InvokePrintDlgEx() As DialogResult

.

        Dim _pdex As PRINTDLGEX = New PRINTDLGEX()

.

        Dim _ppr As PRINTPAGERANGE = New PRINTPAGERANGE()

.

        Dim prnsettings As Printing.PrinterSettings = New Printing.PrinterSettings()

.

        _pdex.lpPrintTemplateName = Nothing

.

        _pdex.Flags = PRINTFLAG.PD_NOSELECTION Or PRINTFLAG.PD_NOPAGENUMS

.

        Return IIf(PrintDlgEx(_pdex), DialogResult.OK, DialogResult.Cancel)

.

Public Class PRINTDLGEX

.

    Public lpPrintTemplateName As String

.

Public Class PRINTPAGERANGE

.

Public Class PRINTFLAG

.

    Public Const PD_PRINTTOFILE As Int32 = 32

.

    Public Const PD_PRINTSETUP As Int32 = 64

.

    Public Const PD_ENABLEPRINTHOOK As Int32 = 4096

.

    Public Const PD_ENABLEPRINTTEMPLATE As Int32 = 16384

.

    Public Const PD_ENABLEPRINTTEMPLATEHANDLE As Int32 = 65536

.

    Public Const PD_DISABLEPRINTTOFILE As Int32 = 524288

.

    Public Const PD_HIDEPRINTTOFILE As Int32 = 1048576

.
Documentation
[PrintDlgEx] on MSDN

winspool

.
Summary
.

static extern int AbortPrinter(IntPtr hPrinter);

.
Summary
.

    internal static extern bool AddPrinterConnection(String pszBuffer);

.

Declare Function AddPrinterConnection Lib "winspool.dll" (TODO) As TODO

.
Documentation
[AddPrinterConnection] on MSDN
.
Summary
.

    internal static extern bool AddPrinterConnection(String pszBuffer);

.

Declare Function AddPrinterConnection Lib "winspool.dll" (TODO) As TODO

.
Documentation
[AddPrinterConnection] on MSDN
.
Summary
Closes a printer connection given a handle
.

static extern int ClosePrinter(IntPtr hPrinter);        

.

<DllImport("winspool.drv", EntryPoint:="ClosePrinter", _

.

Private Shared Function ClosePrinter(ByVal hPrinter As Int32) As Boolean

.
Documentation
[ClosePrinter] on MSDN
.
Summary
DeletePrinterConnection - disconnect / remove client connection to a shared printer
.

internal static extern bool DeletePrinterConnection(String pName);

.

Declare Function DeletePrinterConnection Lib "winspool.dll" (TODO) As TODO

.

result = DeletePrinterConnection("\\\\Server_Name\\Printer_Share");

.
Documentation
[DeletePrinterConnection] on MSDN
.
Summary
Brings up a printer properties page
.

static extern int DocumentProperties(IntPtr hwnd, IntPtr hPrinter, [MarshalAs(UnmanagedType.LPWStr)] string pDeviceName, IntPtr pDevModeOutput, IntPtr pDevModeInput, int fMode);

.

static extern int DocumentProperties(IntPtr hWnd, IntPtr hPrinter, string pDeviceName, IntPtr pDevModeOutput, IntPtr pDevModeInput, fModes fMode);

.

    Private Shared Function DocumentProperties(ByVal hwnd As IntPtr, ByVal hPrinter As IntPtr, <MarshalAs(UnmanagedType.LPWStr)> ByVal pDeviceName As String, ByVal pDevModeOutput As IntPtr, ByVal pDevModeInput As IntPtr, ByVal fMode As Integer) As Integer

.

"DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, pDevMode, pDevMode, 0);" returns -1 and error code 183 under x64 however i dnt knw y!

.

in order to get it working use "DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 0);"

.

Obtain a pointer to the DEVMODE struct (either printerHandle or printerName can be NULL | IntPtr.ZERO):

.

public IntPtr GetDevMode(IntPtr printerHandle, string printerName)

.

   int sizeNeeded = DocumentProperties(IntPtr.Zero, printerHandle, printerName, IntPtr.Zero, IntPtr.Zero, fModes.DM_SIZEOF);

.

   int result = DocumentProperties(IntPtr.Zero, printerHandle, printerName, pdevmode, IntPtr.Zero, fModes.DM_OUT_BUFFER);

.

    private void OpenPrinterPropertiesDialog(PrinterSettings printerSettings)

.

        IntPtr hDevMode = printerSettings.GetHdevmode(printerSettings.DefaultPageSettings);

.

        int sizeNeeded = DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, pDevMode, pDevMode, 0);

.

        DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, devModeData, pDevMode, 14);

.

        printerSettings.SetHdevmode(devModeData);

.

        printerSettings.DefaultPageSettings.SetHdevmode(devModeData);

.

    private void OpenPrinterPropertiesDialog(PrinterSettings printerSettings)

.

        IntPtr hDevMode = printerSettings.GetHdevmode(printerSettings.DefaultPageSettings);

.

        int sizeNeeded = DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, pDevMode, pDevMode, 0);

.

        DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 14);

.

        printerSettings.SetHdevmode(devModeData);

.

        printerSettings.DefaultPageSettings.SetHdevmode(devModeData);

.

    private void OpenPrinterPropertiesDialog(PrinterSettings printerSettings)

.

        IntPtr hDevMode = printerSettings.GetHdevmode(printerSettings.DefaultPageSettings);

.

        int sizeNeeded = DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 0);

.

        DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 14);

.

        printerSettings.SetHdevmode(devModeData);

.

        printerSettings.DefaultPageSettings.SetHdevmode(devModeData);

.

I had to fixed Matthias solution, because it doesn't work well for me. Exception is no more occurs, but when some setting is changed in printer properties it isn't used by printer. I've changed second call of DocumentProperties method. The third-from-last paramter MUST be in this case devModeData.

.

    private void OpenPrinterPropertiesDialog(PrinterSettings printerSettings)

.

        IntPtr hDevMode = printerSettings.GetHdevmode(printerSettings.DefaultPageSettings);

.

        int sizeNeeded = DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, IntPtr.Zero, pDevMode, 0);

.

        DocumentProperties(this.Handle, IntPtr.Zero, printerSettings.PrinterName, devModeData, pDevMode, 14);

.

        printerSettings.SetHdevmode(devModeData);

.

        printerSettings.DefaultPageSettings.SetHdevmode(devModeData);

.

Agreed that the use of a IntPrt.Zero where a recipient data structure is expected looks wrong, but it should be ok in this case: that first call to DocumentProperties does not attempt to save any data to the DevMode structure, it just returns the size of memory necessary to hold all the devModeData held by the printer driver, nothing else.

.

    /// structure contains printer driver information

.

        /// A pointer to a null-terminated string that specifies a language monitor (for example, "PJL monitor"). This member can be NULL and should be specified only for printers capable of bidirectional communication.

.

        /// A pointer to a null-terminated string that specifies the default data type of the print job (for example, "EMF").

.

        /// A pointer to a null-terminated string that specifies previous printer driver names that are compatible with this driver. For example, OldName1\0OldName2\0\0.

.

        /// Pointer to a null-terminated string that specifies the hardware ID for the printer driver.

.

        /// Pointer to a null-terminated string that specifies the provider of the printer driver (for example, "Microsoft Windows 2000")

.
Summary
Contains printer driver information.
.

        public string pszPrintProcessor;

.

        uint dwPrinterDriverAttributes;

.
Summary
.

static extern int EndDocPrinter(IntPtr hPrinter);

.
Summary
.

static extern int EndPagePrinter(IntPtr hPrinter);

.
Summary
The EnumJobs function retrieves information about a specified set of print jobs for a specified printer.
.

   IntPtr hPrinter,                    // handle to printer object

.

    (ByVal hPrinter As IntPtr, _

.

    Public pPrinterName As IntPtr

.

    Public PagesPrinter As Integer

.
Summary
The EnumPrinterDrivers function enumerates the printer drivers installed on a specified printer server
.

    static extern bool EnumPrinterDrivers(String pName, String pEnvironment, uint level, IntPtr pDriverInfo, uint cdBuf, ref uint pcbNeeded, ref uint pcRetruned);

.

Declare Function EnumPrinterDrivers Lib "winspool.dll" (TODO) As TODO

.

private DRIVER_INFO_2[] GetInstalledPrinterDrivers()

.

        'call EnumPrinterDrivers with cbBuffer set

.

        if (EnumPrinterDrivers(null, null, 2, IntPtr.Zero, 0, ref cbNeeded, ref cReturned))

.

        throw new Exception("EnumPrinters should fail!");

.

        if (EnumPrinterDrivers(null, null, 2, pAddr, cbNeeded, ref cbNeeded, ref cReturned))

.

        DRIVER_INFO_2[] printerInfo2 = new DRIVER_INFO_2[cReturned];

.

            printerInfo2[i] = (DRIVER_INFO_2)Marshal.PtrToStructure(new IntPtr(offset), type);

.

        return printerInfo2;

.
Documentation
[EnumPrinterDrivers] on MSDN
.
Summary
Used to enumerate printer-information. See PrinterEnumFlags for the flags. See PRINTER_INFO_2 for the structure for level 2 info.
.

private static extern bool EnumPrinters(PrinterEnumFlags Flags, string Name, uint Level, IntPtr pPrinterEnum, uint cbBuf, ref uint pcbNeeded, ref uint pcReturned);

.

PRINTER_INFO_2

.

PrinterEnumFlags

.

public static PRINTER_INFO_2[] enumPrinters(PrinterEnumFlags Flags)

.

    if (EnumPrinters(Flags, null, 2, IntPtr.Zero, 0, ref cbNeeded, ref cReturned))

.

    if (EnumPrinters(Flags, null, 2, pAddr, cbNeeded, ref cbNeeded, ref cReturned))

.

        PRINTER_INFO_2[] printerInfo2 = new PRINTER_INFO_2[cReturned];

.

        Type type = typeof(PRINTER_INFO_2);

.

        printerInfo2[i] = (PRINTER_INFO_2)Marshal.PtrToStructure(new IntPtr(offset), type);

.

        return printerInfo2;

.

PrinterSettings.InstalledPrinters, but this only gives the name of the printers.

.
Documentation
[EnumPrinters] on MSDN
.
Summary
List supported datatypes of printer
.

[DllImport("winspool.drv", EntryPoint="EnumPrintProcessorDatatypes")]

.

public static extern int EnumPrintProcessorDatatypesA(string pName, string pPrintProcessorName, int Level, ref byte pDatatypes, int cdBuf, ref int pcbNeeded, ref int pcRetruned)

.

Declare Function EnumPrintProcessorDatatypes Lib "winspool.drv" Alias "EnumPrintProcessorDatatypesA" (ByVal pName As String, ByVal pPrintProcessorName As String, ByVal Level As Integer, ByRef pDatatypes As Byte, ByVal cdBuf As Integer, ByRef pcbNeeded As Integer, ByRef pcRetruned As Integer) As Integer

.

public static class PrintProcessor {

.

    private static extern bool EnumPrintProcessorDatatypes(string name,

.

    string printProcessorName, UInt32 level, IntPtr dataTypesBuf,

.

    public static IEnumerable<string> GetPrintProcessorDataTypes(string printProcessorName) {

.

    return GetPrintProcessorDataTypes(string.Empty, printProcessorName);

.

    public static IEnumerable<string> GetPrintProcessorDataTypes(string serverName, string printProcessorName) {

.

    if (EnumPrintProcessorDatatypes(serverName, printProcessorName, 1, IntPtr.Zero, 0, ref bytesNeeded, ref numStructsReturned)) {

.

        if (EnumPrintProcessorDatatypes(serverName, printProcessorName, 1, rawBuffer, bytesNeeded, ref bytesNeeded, ref numStructsReturned)) {

.
Documentation
[EnumPrintProcessorDatatypes] on MSDN
.
Summary
Enumerates the PrintProcessors on a specified server
.

      private static extern bool EnumPrintProcessors(string pName,string pEnvironment,UInt32 Level,IntPtr pPrintProcessorInfo,UInt32 cbBuf,

.

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

.

PRINTPROCESSOR_INFO_1

.

     if (EnumPrintProcessors("","",1,IntPtr.Zero, 0, ref cbNeeded, ref cReturned))

.

        if (EnumPrintProcessors("", "", 1, pAddr, cbNeeded , ref cbNeeded, ref cReturned))

.

           PRINTPROCESSOR_INFO_1[] printprocessorInfo1 = new PRINTPROCESSOR_INFO_1[cReturned];

.

           Type type = typeof(PRINTPROCESSOR_INFO_1);

.

          printprocessorInfo1[i] = (PRINTPROCESSOR_INFO_1)Marshal.PtrToStructure(new IntPtr(offset), type);

.

           return printprocessorInfo1;

.
Documentation
[EnumPrintProcessors] on MSDN
.

    EntryPoint = "FindFirstPrinterChangeNotification",

.

    public static extern IntPtr FindFirstPrinterChangeNotification(

.

        [In] IntPtr hPrinter,

.

        PRINTER_NOTIFY_OPTIONS pPrinterNotifyOptions);

.

Declare Function FindFirstPrinterChangeNotification Lib "winspool.dll" (TODO) As TODO

.

PRINTER_NOTIFY_OPTIONS

.
Documentation
[FindFirstPrinterChangeNotification] on MSDN
.

[DllImport("winspool.Drv", EntryPoint="FlushPrinter", SetLastError=true, CharSet=CharSet.Ansi,ExactSpelling=true, CallingConvention=CallingConvention.StdCall)]

.

private static extern bool FlushPrinter(IntPtr hPrinter,IntPtr pBuf,Int32 cbBuf,out Int32 pcWritten,Int32 cSleep);

.

Declare Function FlushPrinter Lib "winspool.dll" (TODO) As TODO

.
Documentation
[FlushPrinter] on MSDN
.

The GetDefaultPrinter function retrieves the printer name of the default printer for the current user on the local computer

.

public static extern bool GetDefaultPrinter(StringBuilder pszBuffer, ref int pcchBuffer);

.

Declare Function GetDefaultPrinter Lib "winspool.drv" Alias "GetDefaultPrinterA" _

.

Works even if print spooler service is stopped (W2K)

.

public static String getDefaultPrinter()

.

    if (GetDefaultPrinter(null, ref pcchBuffer))

.

    if (GetDefaultPrinter(pszBuffer, ref pcchBuffer))

.
Documentation
[GetDefaultPrinter] on MSDN
.

    static extern bool GetPrinterDriverDirectory(StringBuilder pName,

.

Declare Function GetPrinterDriverDir Lib "winspool.dll" (TODO) As TODO

.

    private String GetPrinterDriverDir()

.

        GetPrinterDriverDirectory(null, null, 1, str, 1024, ref i);

.
Documentation
[GetPrinterDriverDir] on MSDN

Cut off search results after 60. Please refine your search.


 
Access PInvoke.net directly from VS: