From 980e48a91d999f5832af9323e730d9d99fee7907 Mon Sep 17 00:00:00 2001 From: David Hall Date: Sat, 14 Dec 2019 16:30:28 -0700 Subject: [PATCH] Added GDI Print Api Functions to Gdi32 and WinSpool --- PInvoke/Gdi32/WinGdi.Print.cs | 1757 +++++++++++++++++++++++++++++++--- PInvoke/Printing/WinSpool.Enums.cs | 272 +++++- PInvoke/Printing/WinSpool.Funcs.cs | 296 ++++++ PInvoke/Printing/WinSpool.Structs.cs | 173 ++-- 4 files changed, 2241 insertions(+), 257 deletions(-) diff --git a/PInvoke/Gdi32/WinGdi.Print.cs b/PInvoke/Gdi32/WinGdi.Print.cs index 67c11e85..5e633700 100644 --- a/PInvoke/Gdi32/WinGdi.Print.cs +++ b/PInvoke/Gdi32/WinGdi.Print.cs @@ -1,139 +1,1642 @@ -using System.Runtime.InteropServices; +using System; +using System.Drawing; +using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Gdi32 { - /* - __Print Job Functions__ - AddJob - The AddJob function adds a print job to the list of print jobs that can be scheduled by the print spooler. The function retrieves the name of the file you can use to store the job. - ClosePrinter - The ClosePrinter function closes the specified printer object. - DocumentEvent - The DocumentEvent function is an event handler for events associated with printing a document. - DocumentProperties - The DocumentProperties function retrieves or modifies printer initialization information or displays a printer-configuration property sheet for the specified printer. - EndDocPrinter - The EndDocPrinter function ends a print job for the specified printer. - EndPagePrinter - The EndPagePrinter function notifies the print spooler that the application is at the end of a page in a print job. - EnumJobs - The EnumJobs function retrieves information about a specified set of print jobs for a specified printer. - GetJob - The GetJob function retrieves information about a specified print job. - OpenPrinter - The OpenPrinter function retrieves a handle to the specified printer or print server or other types of handles in the print subsystem. - OpenPrinter2 - Retrieves a handle to the specified printer, print server, or other types of handles in the print subsystem, while setting some of the printer options. - ReportJobProcessingProgress - Reports to the Print Spooler service whether an XPS print job is in the spooling or the rendering phase and what part of the processing is currently underway. - ScheduleJob - The ScheduleJob function requests that the print spooler schedule a specified print job for printing. - SetJob - The SetJob function pauses, resumes, cancels, or restarts a print job on a specified printer. You can also use the SetJob function to set print job parameters, such as the print job priority and the document name. - StartDocPrinter - The StartDocPrinter function notifies the print spooler that a document is to be spooled for printing. - StartPagePrinter - The StartPagePrinter function notifies the spooler that a page is about to be printed on the specified printer. + /// + public const int SP_APPABORT = (-2); - __Printer User Interface Functions__ - AdvancedDocumentProperties - The AdvancedDocumentProperties function displays a printer-configuration dialog box for the specified printer, allowing the user to configure that printer. - ConfigurePort - The ConfigurePort function displays the port-configuration dialog box for a port on the specified server. - ConnectToPrinterDlg - The ConnectToPrinterDlg function displays a dialog box that lets users browse and connect to printers on a network. If the user selects a printer, the function attempts to create a connection to it; if a suitable driver is not installed on the server, the user is given the option of creating a printer locally. - PrinterProperties - The PrinterProperties function displays a printer-properties property sheet for the specified printer. + /// + public const int SP_ERROR = (-1); - __Printer Functions__ - AbortPrinter - The AbortPrinter function deletes a printer's spool file if the printer is configured for spooling. - AddPrinter - The AddPrinter function adds a printer to the list of supported printers for a specified server. - AddPrinterConnection - The AddPrinterConnection function adds a connection to the specified printer for the current user. - AddPrinterConnection2 - Adds a connection to the specified printer for the current user and specifies connection details. - DeletePrinter - The DeletePrinter function deletes the specified printer object. - DeletePrinterConnection - The DeletePrinterConnection function deletes a connection to a printer that was established by a call to AddPrinterConnection or ConnectToPrinterDlg. - DeletePrinterData - The DeletePrinterData function deletes specified configuration data for a printer. A printer's configuration data consists of a set of named and typed values. The DeletePrinterData function deletes one of these values, specified by its value name. - DeletePrinterDataEx - The DeletePrinterDataEx function deletes a specified value from the configuration data for a printer. A printer's configuration data consists of a set of named and typed values stored in a hierarchy of registry keys. The function deletes a specified value under a specified key. - DeletePrinterKey - The DeletePrinterKey function deletes a specified key and all its subkeys for a specified printer. - EnumPrinterData - The EnumPrinterData function enumerates configuration data for a specified printer. - EnumPrinterDataEx - The EnumPrinterDataEx function enumerates all value names and data for a specified printer and key. - EnumPrinterKey - The EnumPrinterKey function enumerates the subkeys of a specified key for a specified printer. - EnumPrinters - The EnumPrinters function enumerates available printers, print servers, domains, or print providers. - FlushPrinter - The FlushPrinter function sends a buffer to the printer in order to clear it from a transient state. - GetDefaultPrinter - The GetDefaultPrinter function retrieves the printer name of the default printer for the current user on the local computer. - GetPrinter - The GetPrinter function retrieves information about a specified printer. - GetPrinterData - The GetPrinterData function retrieves configuration data for the specified printer or print server. - GetPrinterDataEx - The GetPrinterDataEx function retrieves configuration data for the specified printer or print server. GetPrinterDataEx can retrieve values stored by the SetPrinterData function. In addition, GetPrinterDataEx can retrieve values stored under a specified key by the SetPrinterDataEx function. - IsValidDevmode - The IsValidDevmode function verifies that the contents of a DEVMODE structure are valid. - ReadPrinter - The ReadPrinter function retrieves data from the specified printer. - ResetPrinter - The ResetPrinter function specifies the data type and device mode values to be used for printing documents submitted by the StartDocPrinter function. These values can be overridden by using the SetJob function after document printing has started. - SetDefaultPrinter - The SetDefaultPrinter function sets the printer name of the default printer for the current user on the local computer. - SetPort - The SetPort function sets the status associated with a printer port. - SetPrinter - The SetPrinter function sets the data for a specified printer or sets the state of the specified printer by pausing printing, resuming printing, or clearing all print jobs. - SetPrinterData - The SetPrinterData function sets the configuration data for a printer or print server. - SetPrinterDataEx - The SetPrinterDataEx function sets the configuration data for a printer or print server. The function stores the configuration data under the printer's registry key. - WritePrinter - The WritePrinter function notifies the print spooler that data should be written to the specified printer. + /// + public const int SP_NOTREPORTED = 0x4000; - __Printer Change Notification Functions__ - FindClosePrinterChangeNotification - The FindClosePrinterChangeNotification function closes a change notification object created by calling the FindFirstPrinterChangeNotification function. The printer or print server associated with the change notification object will no longer be monitored by that object. - FindFirstPrinterChangeNotification - The FindFirstPrinterChangeNotification function creates a change notification object and returns a handle to the object. You can then use this handle in a call to one of the wait functions to monitor changes to the printer or print server. - FindNextPrinterChangeNotification - The FindNextPrinterChangeNotification function retrieves information about the most recent change notification for a change notification object associated with a printer or print server. Call this function when a wait operation on the change notification object is satisfied. - FreePrinterNotifyInfo - The FreePrinterNotifyInfo function frees a system-allocated buffer created by the FindNextPrinterChangeNotification function. + /// + public const int SP_OUTOFDISK = (-4); - __Printer Form Functions__ - AddForm - The AddForm function adds a form to the list of available forms that can be selected for the specified printer. - DeleteForm - The DeleteForm function removes a form name from the list of supported forms. - EnumForms - The EnumForms function enumerates the forms supported by the specified printer. - GetForm - The GetForm function retrieves information about a specified form. - SetForm - The SetForm function sets the form information for the specified printer. + /// + public const int SP_OUTOFMEMORY = (-5); - __Print Spooler Functions__ - CloseSpoolFileHandle - The CloseSpoolFileHandle function closes a handle to a spool file associated with the print job currently submitted by the application. - CommitSpoolData - The CommitSpoolData function notifies the print spooler that a specified amount of data has been written to a specified spool file and is ready to be rendered. - GetPrintExecutionData - The GetPrintExecutionData retrieves the current print context. - GetSpoolFileHandle - The GetSpoolFileHandle function retrieves a handle for the spool file associated with the job currently submitted by the application. - */ + /// + public const int SP_USERABORT = (-3); + + /// + /// The AbortProc function is an application-defined callback function used with the SetAbortProc function. It is called when + /// a print job is to be canceled during spooling. The ABORTPROC type defines a pointer to this callback function. + /// AbortProc is a placeholder for the application-defined function name. + /// + /// A handle to the device context for the print job. + /// + /// Specifies whether an error has occurred. This parameter is zero if no error has occurred; it is SP_OUTOFDISK if Print Manager is + /// currently out of disk space and more disk space will become available if the application waits. + /// + /// The callback function should return TRUE to continue the print job or FALSE to cancel the print job. + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// + /// If the iError parameter is SP_OUTOFDISK, the application need not cancel the print job. If it does not cancel the job, it must + /// yield to Print Manager by calling the PeekMessage or GetMessage function. + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nc-wingdi-abortproc ABORTPROC Abortproc; BOOL Abortproc( HDC Arg1, int + // Arg2 ) {...} + [PInvokeData("wingdi.h", MSDNShortId = "3728a491-28ff-49ec-9131-ed6238b2be3d")] + [UnmanagedFunctionPointer(CallingConvention.Winapi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool AbortProc(HDC hdc, int iError); + + /// Specifies additional information about the print job. + [PInvokeData("wingdi.h", MSDNShortId = "329bf0d9-399b-4f64-a029-361ef7558aeb")] + public enum DI + { + /// Applications that use banding should set this flag for optimal performance during printing. + DI_APPBANDING = 0x00000001, + + /// The application will use raster operations that involve reading from the destination surface. + DI_ROPS_READ_DESTINATION = 0x00000002 + } + + /// The escape function to be performed. + [PInvokeData("wingdi.h", MSDNShortId = "5ca74f61-75dd-4a8c-9f0f-9c1b4719c75f")] + public enum EscapeFunction + { + NEWFRAME = 1, + ABORTDOC = 2, + NEXTBAND = 3, + SETCOLORTABLE = 4, + GETCOLORTABLE = 5, + FLUSHOUTPUT = 6, + DRAFTMODE = 7, + + /// Determines whether a particular escape is implemented by the device driver. + QUERYESCSUPPORT = 8, + + SETABORTPROC = 9, + STARTDOC = 10, + ENDDOC = 11, + GETPHYSPAGESIZE = 12, + GETPRINTINGOFFSET = 13, + GETSCALINGFACTOR = 14, + MFCOMMENT = 15, + GETPENWIDTH = 16, + SETCOPYCOUNT = 17, + SELECTPAPERSOURCE = 18, + DEVICEDATA = 19, + + /// + /// The PASSTHROUGH printer escape function sends data directly to a printer driver. + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// PASSTHROUGH + /// + /// + /// cjInput + /// The number of bytes of data to which the lpszInData parameter points. + /// + /// + /// lpInData + /// + /// A pointer to the input structure required for the specified escape. The first word in the buffer contains the number of + /// bytes of input data. The remaining bytes of the buffer contain the data itself. + /// + /// + /// + /// cjOutput + /// + /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this + /// parameter is 0. + /// + /// + /// + /// lpOutData + /// + /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the + /// parameter is NULL. + /// + /// + /// + /// + PASSTHROUGH = 19, + + /// + /// The GETTECHNOLOGY printer escape function identifies the type of printer driver. + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// GETTECHNOLOGY + /// + /// + /// cjInput + /// The number of bytes of data to which the lpszInData parameter points. + /// + /// + /// lpInData + /// A pointer to the input structure required for the specified escape. + /// + /// + /// cjOutput + /// The number of bytes of data to which the lpszOutData parameter points. + /// + /// + /// lpOutData + /// + /// A pointer to the structure that receives output from this escape. This parameter must not be NULL if ExtEscape is called as + /// a query function. If no data is to be returned in this structure, set cbOutput to 0. + /// + /// + /// + /// + GETTECHNOLOGY = 20, + + SETLINECAP = 21, + SETLINEJOIN = 22, + SETMITERLIMIT = 23, + BANDINFO = 24, + + /// + /// The DRAWPATTERNRECT printer escape creates a white, gray scale, or solid black rectangle by using the pattern and rule + /// capabilities of Page Control Language (PCL) on Hewlett-Packard LaserJet or LaserJet-compatible printers. A gray scale is a + /// gray pattern that contains a specific mixture of black and white pixels. + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// DRAWPATTERNRECT + /// + /// + /// cjInput + /// The number of bytes of data to which the lpszInData parameter points. + /// Set this value to sizeof(DRAWPATRECT). + /// + /// + /// + /// lpInData + /// A pointer to a DRAWPATTERNRECT structure that describes the rectangle. + /// + /// + /// cjOutput + /// The number of bytes of data to which the lpszOutData parameter points. + /// For this escape, the value of this parameter is 0. + /// + /// + /// + /// lpOutData + /// A pointer to the structure that will receive output from this escape. + /// For this printer escape function, the value of the parameter is NULL. + /// + /// + /// + /// + DRAWPATTERNRECT = 25, + + GETVECTORPENSIZE = 26, + GETVECTORBRUSHSIZE = 27, + ENABLEDUPLEX = 28, + GETSETPAPERBINS = 29, + GETSETPRINTORIENT = 30, + ENUMPAPERBINS = 31, + SETDIBSCALING = 32, + EPSPRINTING = 33, + ENUMPAPERMETRICS = 34, + GETSETPAPERMETRICS = 35, + + /// + /// The POSTSCRIPT_DATA printer escape function sends data directly to a printer driver. + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// POSTSCRIPT_DATA + /// + /// + /// cjInput + /// The number of bytes of data to which the lpszInData parameter points. + /// + /// + /// lpInData + /// + /// A pointer to the input structure required for the specified escape. The first word in the buffer contains the number of + /// bytes of input data. The remaining bytes of the buffer contain the data itself. + /// + /// + /// + /// cjOutput + /// + /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this + /// parameter is 0. + /// + /// + /// + /// lpOutData + /// + /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the + /// parameter is NULL. + /// + /// + /// + /// + POSTSCRIPT_DATA = 37, + + POSTSCRIPT_IGNORE = 38, + MOUSETRAILS = 39, + GETDEVICEUNITS = 42, + GETEXTENDEDTEXTMETRICS = 256, + GETEXTENTTABLE = 257, + GETPAIRKERNTABLE = 258, + GETTRACKKERNTABLE = 259, + EXTTEXTOUT = 512, + GETFACENAME = 513, + DOWNLOADFACE = 514, + ENABLERELATIVEWIDTHS = 768, + ENABLEPAIRKERNING = 769, + SETKERNTRACK = 770, + SETALLJUSTVALUES = 771, + SETCHARSET = 772, + STRETCHBLT = 2048, + METAFILE_DRIVER = 2049, + GETSETSCREENPARAMS = 3072, + QUERYDIBSUPPORT = 3073, + BEGIN_PATH = 4096, + CLIP_TO_PATH = 4097, + END_PATH = 4098, + EXT_DEVICE_CAPS = 4099, + RESTORE_CTM = 4100, + SAVE_CTM = 4101, + SET_ARC_DIRECTION = 4102, + SET_BACKGROUND_COLOR = 4103, + SET_POLY_MODE = 4104, + SET_SCREEN_ANGLE = 4105, + SET_SPREAD = 4106, + TRANSFORM_CTM = 4107, + SET_CLIP_BOX = 4108, + SET_BOUNDS = 4109, + SET_MIRROR_MODE = 4110, + OPENCHANNEL = 4110, + DOWNLOADHEADER = 4111, + CLOSECHANNEL = 4112, + + /// + /// The POSTSCRIPT_PASSTHROUGH printer escape function sends data directly to a PostScript printer driver. + /// + /// A PostScript driver supports this escape function when in PostScript-centric mode or in compatibility mode, but not in + /// GDI-centric mode. + /// + /// To set the PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// POSTSCRIPT_PASSTHROUGH + /// + /// + /// cjInput + /// The number of bytes of data to which the lpszInData parameter points. + /// + /// + /// lpInData + /// + /// A pointer to the input structure required for the specified escape. The first word in the buffer contains the number of + /// bytes of input data. The remaining bytes of the buffer contain the data itself. + /// + /// + /// + /// cjOutput + /// + /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this + /// parameter is 0. + /// + /// + /// + /// lpOutData + /// + /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the + /// parameter is NULL. + /// + /// + /// + /// + POSTSCRIPT_PASSTHROUGH = 4115, + + ENCAPSULATED_POSTSCRIPT = 4116, + + /// + /// The POSTSCRIPT_IDENTIFY printer escape function sets a PostScript driver to GDI-centric mode or PostScript-centric mode. + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// POSTSCRIPT_IDENTIFY + /// + /// + /// cjInput + /// The number of bytes of data to which the lpszInData parameter points. + /// For this escape, set this value to sizeof(DWORD). + /// + /// + /// + /// lpInData + /// A pointer to the input structure required for the specified escape. + /// + /// + /// Value + /// Meaning + /// + /// + /// PSIDENT_GDICENTRIC + /// + /// + /// GDI-centric mode. Specify this value if the PostScript driver supports the PASSTHROUGH printer escape function, but not the + /// POSTSCRIPT_PASSTHROUGH printer escape function. + /// + /// + /// + /// + /// PSIDENT_PSCENTRIC + /// + /// + /// PostScript-centric mode. Specify this value if the PostScript driver supports the POSTSCRIPT_PASSTHROUGH printer escape + /// function, but not the PASSTHROUGH printer escape function. + /// + /// + /// + /// + /// + /// + /// + /// cjOutput + /// + /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this + /// parameter is 0. + /// + /// + /// + /// lpOutData + /// + /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the + /// parameter is NULL. + /// + /// + /// + /// + POSTSCRIPT_IDENTIFY = 4117, + + /// + /// The POSTSCRIPT_INJECTION printer escape function inserts a block of raw data at a specified point in a PostScript job stream. + /// + /// A PostScript driver supports this escape function in GDI-centric mode or PostScript-centric mode support, but not in + /// compatibility mode. + /// + /// To set the PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// POSTSCRIPT_INJECTION + /// + /// + /// cjInput + /// The number of bytes of data to which the lpszInData parameter points. + /// Set this parameter to sizeof(PSINJECTDATA) plus the size of the raw data to inject. + /// + /// + /// + /// lpInData + /// A pointer to the buffer that contains a PSINJECTDATA structure followed by the raw data to inject. + /// + /// + /// cjOutput + /// + /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this + /// parameter is 0. + /// + /// + /// + /// lpOutData + /// + /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the + /// parameter is NULL. + /// + /// + /// + /// + POSTSCRIPT_INJECTION = 4118, + + /// + /// The CHECKJPEGFORMAT printer escape function determines whether a printer supports printing a JPEG image. + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// CHECKJPEGFORMAT + /// + /// + /// cjInput + /// The size, in bytes, of the JPEG image buffer pointed to by the lpInData parameter. + /// + /// + /// lpInData + /// A pointer to a buffer that contains the JPEG image. + /// + /// + /// cjOutput + /// The number of bytes of data pointed to by the lpOutData parameter. + /// For this escape, set this value to sizeof(DWORD). + /// + /// + /// + /// lpOutData + /// + /// A pointer to the DWORD variable that receives the output from this escape. This parameter must not be NULL. + /// If the printer supports the image type, this value is set to 1. Otherwise, it is set to zero. + /// + /// + /// + /// + CHECKJPEGFORMAT = 4119, + + /// + /// The CHECKJPEGFORMAT printer escape function determines whether a printer supports printing a PNG image. + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// CHECKPNGFORMAT + /// + /// + /// cjInput + /// The size, in bytes, of the PNG image buffer pointed to by the lpInData parameter. + /// + /// + /// lpInData + /// A pointer to a buffer that contains the PNG image. + /// + /// + /// cjOutput + /// The number of bytes of data pointed to by the lpOutData parameter. + /// For this escape, set this value to sizeof(DWORD). + /// + /// + /// + /// lpOutData + /// + /// A pointer to the DWORD variable that receives the output from this escape. This parameter must not be NULL. + /// If the printer supports the image type, this value is set to 1. Otherwise, it is set to zero. + /// + /// + /// + /// + CHECKPNGFORMAT = 4120, + + /// + /// The GET_PS_FEATURESETTING printer escape function retrieves information about a specified feature setting for a PostScript driver. + /// + /// This escape function is supported only if the PostScript driver is in PostScript-centric mode or in GDI-centric mode. To set + /// the PostScript driver mode, call the POSTSCRIPT_IDENTIFY escape function. + /// + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// DRAWPATTERNRECT + /// + /// + /// cjInput + /// The number of bytes of data to which the lpszInData parameter points. + /// Set this value to sizeof(INT). + /// + /// + /// + /// lpInData + /// A pointer to the INT variable that contains a feature setting value from the following table. + /// + /// Windows XP and later versions of Windows support the private use of this parameter. For private use, you can use the numbers + /// in the range from FEATURESETTING_PRIVATE_BEGIN to FEATURESETTING_PRIVATE_END. Private parties that intend to use numbers in + /// this range should contact Microsoft first to avoid conflicts with other applications. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// FEATURESETTING_CUSTPAPER + /// + /// Retrieves the custom paper parameters. + /// Set cbOutput to sizeof ( PSFEATURE_CUSTPAPER ) and lpszOutData to point to a PSFEATURE_CUSTPAPER structure. + /// + /// + /// + /// FEATURESETTING_MIRROR + /// + /// Retrieves the mirrored output setting. + /// Set cbOutput to sizeof ( BOOL ) and lpszOutData to point to a BOOL variable. + /// If mirrored output is selected, the value returned in lpszOutData is TRUE. + /// If mirrored output is not selected, the value returned in lpszOutData is FALSE + /// + /// + /// + /// FEATURESETTING_NEGATIVE + /// + /// Retrieves the negative output setting. + /// Set cbOutput to sizeof ( BOOL ) and lpszOutData to point to a BOOL variable. + /// + /// When the function returns, the lpszOutData variable is TRUE if "Negative Output: Yes" is selected; otherwise, it is FALSE. + /// + /// + /// + /// + /// FEATURESETTING_NUP + /// + /// Retrieves the N-Up setting of the page layout. + /// Set cbOutput to sizeof ( BOOL ) and lpszOutData to point to a BOOL variable. + /// If an N-Up page layout is not being used, the lpszOutData variable returns FALSE. + /// + /// If an N-Up page layout is being used, the lpszOutData variable returns TRUE. However, the variable does not indicate the + /// format of the N-Up page layout or its semantics. + /// + /// + /// + /// + /// FEATURESETTING_OUTPUT + /// + /// Retrieves information about PostScript driver output options. + /// Set cbOutput to sizeof ( PSFEATURE_OUTPUT ) and lpszOutData to point to a PSFEATURE_OUTPUT structure. + /// + /// + /// + /// FEATURESETTING_PROTOCOL + /// + /// Retrieves the output protocol setting. + /// Sets cbOutput to sizeof( INT ) and lpszOutData to point to an INT variable. + /// When the function returns, the lpszOutData variable is set to one of the following output protocol values: + /// PSPROTOCOL_ASCII PSPROTOCOL_BCP PSPROTOCOL_TBCP PSPROTOCOL_BINARY + /// + /// + /// + /// FEATURESETTING_PSLEVEL + /// + /// Retrieves the PostScript language level. + /// Set cbOutput to sizeof ( INT ) and lpszOutData to point to an INT variable. + /// + /// When the function returns, the lpszOutData variable is set to 1, 2, 3, or higher to indicate the PostScript language level. + /// + /// + /// + /// + /// + /// + /// + /// cjOutput + /// The number of bytes of data to which the lpszOutData parameter points. + /// + /// + /// lpOutData + /// + /// A pointer to the structure that receives output from this escape. This parameter must not be NULL if ExtEscape is called as + /// a query function. If no data is to be returned in this structure, set cbOutput to 0. + /// + /// + /// + /// + GET_PS_FEATURESETTING = 4121, + + GDIPLUS_TS_QUERYVER = 4122, + GDIPLUS_TS_RECORD = 4123, + + /// + /// The SPCLPASSTHROUGH2 printer escape function allows applications that print to PostScript devices using EPSPRINTING to + /// include private PostScript procedures and other resources at the document-level save context. + /// + /// This escape is supported only for backward compatibility with Adobe Acrobat. Other applications should not use this obsolete escape. + /// + /// + /// + /// Parameter + /// Value + /// + /// + /// hdc + /// A handle to the printer device context. + /// + /// + /// iEscape + /// SPCLPASSTHROUGH2 + /// + /// + /// cjInput + /// The number of bytes of data to which the lpszInData parameter points. + /// + /// + /// lpInData + /// A pointer to the input structure required for the specified escape. + /// + /// + /// cjOutput + /// + /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this + /// parameter is 0. + /// + /// + /// + /// lpOutData + /// + /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the + /// parameter is NULL. + /// + /// + /// + /// + SPCLPASSTHROUGH2 = 4568, + } + + /// Specifies where to inject the raw data in the PostScript output. + [PInvokeData("wingdi.h", MSDNShortId = "f42c8f69-7fe9-4740-b295-32ef2a5b714c")] + public enum PSINJECT : ushort + { + /// Before the first byte of job stream. + PSINJECT_BEGINSTREAM = 1, + + /// Before %!PS-Adobe. + PSINJECT_PSADOBE = 2, + + /// Replaces driver's %%Pages (atend). + PSINJECT_PAGESATEND = 3, + + /// Replaces driver's %%Pages nnn. + PSINJECT_PAGES = 4, + + /// After %%DocumentNeededResources. + PSINJECT_DOCNEEDEDRES = 5, + + /// After %%DocumentSuppliedResources. + PSINJECT_DOCSUPPLIEDRES = 6, + + /// Replaces driver's %%PageOrder. + PSINJECT_PAGEORDER = 7, + + /// Replaces driver's %%Orientation. + PSINJECT_ORIENTATION = 8, + + /// Replaces driver's %%BoundingBox. + PSINJECT_BOUNDINGBOX = 9, + + /// Replaces driver's %%DocumentProcessColors <color>. + PSINJECT_DOCUMENTPROCESSCOLORS = 10, + + /// Before %%EndComments. + PSINJECT_COMMENTS = 11, + + /// After %%BeginDefaults. + PSINJECT_BEGINDEFAULTS = 12, + + /// Before %%EndDefaults. + PSINJECT_ENDDEFAULTS = 13, + + /// After %%BeginProlog. + PSINJECT_BEGINPROLOG = 14, + + /// Before %%EndProlog. + PSINJECT_ENDPROLOG = 15, + + /// After %%BeginSetup. + PSINJECT_BEGINSETUP = 16, + + /// TBefore %%EndSetup. + PSINJECT_ENDSETUP = 17, + + /// After %%Trailer + PSINJECT_TRAILER = 18, + + /// After %%EOF + PSINJECT_EOF = 19, + + /// After the last byte of job stream + PSINJECT_ENDSTREAM = 20, + + /// Replaces driver's %%DocumentProcessColors (atend) + PSINJECT_DOCUMENTPROCESSCOLORSATEND = 21, + + /// Replaces driver's %%Page + PSINJECT_PAGENUMBER = 100, + + /// After %%BeginPageSetup + PSINJECT_BEGINPAGESETUP = 101, + + /// Before %%EndPageSetup + PSINJECT_ENDPAGESETUP = 102, + + /// After %%PageTrailer + PSINJECT_PAGETRAILER = 103, + + /// Replace driver's %%PlateColor: <color> + PSINJECT_PLATECOLOR = 104, + + /// Before showpage operator + PSINJECT_SHOWPAGE = 105, + + /// Replaces driver's %%PageBoundingBox + PSINJECT_PAGEBBOX = 106, + + /// Before %%EndPageComments + PSINJECT_ENDPAGECOMMENTS = 107, + + /// Before save operator + PSINJECT_VMSAVE = 200, + + /// After restore operator + PSINJECT_VMRESTORE = 201, + } + + /// + /// The AbortDoc function stops the current print job and erases everything drawn since the last call to the StartDoc function. + /// + /// Handle to the device context for the print job. + /// + /// If the function succeeds, the return value is greater than zero. + /// If the function fails, the return value is SP_ERROR. + /// + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// + /// Applications should call the AbortDoc function to stop a print job if an error occurs, or to stop a print job after the + /// user cancels that job. To end a successful print job, an application should call the EndDoc function. + /// + /// + /// If Print Manager was used to start the print job, calling AbortDoc erases the entire spool job, so that the printer + /// receives nothing. If Print Manager was not used to start the print job, the data may already have been sent to the printer. In + /// this case, the printer driver resets the printer (when possible) and ends the print job. + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-abortdoc int AbortDoc( HDC hdc ); + [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("wingdi.h", MSDNShortId = "4ecc371c-34fa-4073-96fe-0de03b84d7e3")] + public static extern int AbortDoc(HDC hdc); + + /// The EndDoc function ends a print job. + /// Handle to the device context for the print job. + /// + /// If the function succeeds, the return value is greater than zero. + /// If the function fails, the return value is less than or equal to zero. + /// + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// Applications should call EndDoc immediately after finishing a print job. + /// Examples + /// For a sample program that uses this function, see How To: Print Using the GDI Print API. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-enddoc int EndDoc( HDC hdc ); + [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("wingdi.h", MSDNShortId = "bf63ea0f-cc73-4943-9c84-52b3b77e141c")] + public static extern int EndDoc(HDC hdc); + + /// + /// The EndPage function notifies the device that the application has finished writing to a page. This function is typically + /// used to direct the device driver to advance to a new page. + /// + /// A handle to the device context for the print job. + /// + /// If the function succeeds, the return value is greater than zero. + /// If the function fails, the return value is less than or equal to zero. + /// + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// + /// Use the ResetDC function to change the device mode, if necessary, after calling the EndPage function. Note that a call to + /// ResetDC resets all device context attributes back to default values. Neither EndPage nor StartPage resets the + /// device context attributes. Device context attributes remain constant across subsequent pages. You do not need to re-select + /// objects and set up the mapping mode again before printing the next page; however, doing so will produce the same results and + /// reduce code differences between versions of Windows. + /// + /// + /// When a page in a spooled file exceeds approximately 350 MB, it may fail to print and not send an error message. For example, + /// this can occur when printing large EMF files. The page size limit depends on many factors including the amount of virtual memory + /// available, the amount of memory allocated by calling processes, and the amount of fragmentation in the process heap. + /// + /// Examples + /// For a sample program that uses this function, see How To: Print Using the GDI Print API. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-endpage int EndPage( HDC hdc ); + [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("wingdi.h", MSDNShortId = "33e6d005-f00d-4b87-bf7c-fc79c1d05514")] + public static extern int EndPage(HDC hdc); + + /// + /// The Escape function enables an application to access the system-defined device capabilities that are not available + /// through GDI. Escape calls made by an application are translated and sent to the driver. + /// + /// A handle to the device context. + /// + /// The escape function to be performed. This parameter must be one of the predefined escape values listed in Remarks. Use the + /// ExtEscape function if your application defines a private escape value. + /// + /// The number of bytes of data pointed to by the lpvInData parameter. This can be 0. + /// A pointer to the input structure required for the specified escape. + /// + /// A pointer to the structure that receives output from this escape. This parameter should be NULL if no data is returned. + /// + /// + /// + /// If the function succeeds, the return value is greater than zero, except with the QUERYESCSUPPORT printer escape, which checks + /// for implementation only. If the escape is not implemented, the return value is zero. + /// + /// If the function fails, the return value is a system error code. + /// + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// The effect of passing 0 for cbInput will depend on the value of nEscape and on the driver that is handling the escape. + /// Of the original printer escapes, only the following can be used. + /// + /// + /// Escape + /// Description + /// + /// + /// QUERYESCSUPPORT + /// Determines whether a particular escape is implemented by the device driver. + /// + /// + /// PASSTHROUGH + /// Allows the application to send data directly to a printer. + /// + /// + /// For information about printer escapes, see ExtEscape. + /// Use the StartPage function to prepare the printer driver to receive data. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-escape int Escape( HDC hdc, int iEscape, int cjIn, LPCSTR + // pvIn, LPVOID pvOut ); + [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("wingdi.h", MSDNShortId = "ba21b680-78a8-45a2-94e1-01b377b74787")] + public static extern int Escape(HDC hdc, EscapeFunction iEscape, int cjIn, [In] IntPtr pvIn, [Out] IntPtr pvOut); + + /// + /// The ExtEscape function enables an application to access device capabilities that are not available through GDI. + /// + /// A handle to the device context. + /// + /// The escape function to be performed. It can be one of the following or it can be an application-defined escape function. + /// + /// + /// Value + /// Meaning + /// + /// + /// CHECKJPEGFORMAT + /// Checks whether the printer supports a JPEG image. + /// + /// + /// CHECKPNGFORMAT + /// Checks whether the printer supports a PNG image. + /// + /// + /// DRAWPATTERNRECT + /// Draws a white, gray-scale, or black rectangle. + /// + /// + /// GET_PS_FEATURESETTING + /// Gets information on a specified feature setting for a PostScript driver. + /// + /// + /// GETTECHNOLOGY + /// Reports on whether or not the driver is a Postscript driver. + /// + /// + /// PASSTHROUGH + /// Allows the application to send data directly to a printer. Supported in compatibility mode and GDI-centric mode. + /// + /// + /// POSTSCRIPT_DATA + /// Allows the application to send data directly to a printer. Supported only in compatibility mode. + /// + /// + /// POSTSCRIPT_IDENTIFY + /// Sets a PostScript driver to GDI-centric or PostScript-centric mode. + /// + /// + /// POSTSCRIPT_INJECTION + /// Inserts a block of raw data in a PostScript job stream. + /// + /// + /// POSTSCRIPT_PASSTHROUGH + /// Sends data directly to a PostScript printer driver. Supported in compatibility mode and PostScript-centric mode. + /// + /// + /// QUERYESCSUPPORT + /// Determines whether a particular escape is implemented by the device driver. + /// + /// + /// SPCLPASSTHROUGH2 + /// Enables applications to include private procedures and other resources at the document level-save context. + /// + /// + /// + /// The number of bytes of data pointed to by the lpszInData parameter. + /// A pointer to the input structure required for the specified escape. See also Remarks. + /// The number of bytes of data pointed to by the lpszOutData parameter. + /// + /// A pointer to the structure that receives output from this escape. This parameter must not be NULL if ExtEscape is + /// called as a query function. If no data is to be returned in this structure, set cbOutput to 0. See also Remarks. + /// + /// + /// The return value specifies the outcome of the function. It is greater than zero if the function is successful, except for the + /// QUERYESCSUPPORT printer escape, which checks for implementation only. The return value is zero if the escape is not implemented. + /// A return value less than zero indicates an error. + /// + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// Use this function to pass a driver-defined escape value to a device. + /// + /// Use the Escape function to pass one of the system-defined escape values to a device, unless the escape is one of the defined + /// escapes in nEscape. ExtEscape might not work properly with the system-defined escapes. In particular, escapes in which + /// lpszInData is a pointer to a structure that contains a member that is a pointer will fail. + /// + /// + /// Note, that the behavior described in this article is the expected behavior, but it is up to the driver to comply with this model. + /// + /// + /// The variables referenced by lpszInData and lpszOutData should not be the same or overlap. If the input and the output buffer + /// size variables overlap, they may not contain the correct values after the call returns. For the best results, lpszInData and + /// lpszOutData should refer to different variables. + /// + /// The CHECKJPEGFORMAT printer escape function determines whether a printer supports printing a JPEG image. + /// + /// Before using the CHECKJPEGFORMAT printer escape function, call the QUERYESCSUPPORT printer escape function to determine whether + /// the driver supports CHECKJPEGFORMAT. For sample code that demonstrates the use of CHECKJPEGFORMAT, see Testing a + /// Printer for JPEG or PNG Support. + /// + /// The CHECKPNGFORMAT printer escape function determines whether a printer supports printing a PNG image. + /// + /// Before using the CHECKJPEGFORMAT printer escape function, call the QUERYESCSUPPORT printer escape function to determine whether + /// the driver supports CHECKJPEGFORMAT. For sample code, see Testing a Printer for JPEG or PNG Support. + /// + /// + /// The DRAWPATTERNRECT printer escape creates a white, gray scale, or solid black rectangle by using the pattern and rule + /// capabilities of Page Control Language (PCL) on Hewlett-Packard LaserJet or LaserJet-compatible printers. A gray scale is a gray + /// pattern that contains a specific mixture of black and white pixels. + /// + /// + /// An application should use the QUERYESCSUPPORT escape to determine whether the printer is capable of drawing patterns and rules + /// before using the DRAWPATTERNRECT escape. + /// + /// + /// + /// Rules drawn with DRAWPATTERNRECT are not subject to clipping regions in the device context. + /// + /// + /// Applications should not try to erase patterns and rules created with DRAWPATTERNRECT by placing opaque objects over them. + /// + /// + /// + /// If the printer supports white rules, these can be used to erase patterns created by DRAWPATTERNRECT. If the printer does not + /// support white rules, there is no method for erasing these patterns. + /// + /// + /// If an application cannot use the DRAWPATTERNRECT escape and the device is a printer, it should generally use the PatBlt function + /// instead. Note that if PatBlt is used to print a black rectangle, the application should use the BLACKNESS raster + /// operator. If the device is a plotter, however, the application should use the Rectangle function. + /// + /// + /// The GET_PS_FEATURESETTING printer escape function retrieves information about a specified feature setting for a PostScript driver. + /// + /// + /// This escape function is supported only if the PostScript driver is in PostScript-centric mode or in GDI-centric mode. To set the + /// PostScript driver mode, call the POSTSCRIPT_IDENTIFY escape function. + /// + /// To perform this operation, call the ExtEscape function with the following parameters. + /// + /// The GET_PS_FEATURESETTING printer escape function is valid if called any time after calling the CreateDC function and before + /// calling the DeleteDC function. + /// + /// The GETTECHNOLOGY printer escape function identifies the type of printer driver. + /// For non-XPSDrv printers, this escape reports whether the driver is a Postscript driver. + /// + /// For XPSDrv printers, this escape reports whether the driver is the Microsoft XPS Document Converter (MXDC). If it is, the escape + /// returns the zero-terminated string "http://schemas.microsoft.com/xps/2005/06" + /// + /// + /// The PASSTHROUGH printer escape function sends data directly to a printer driver. To perform this operation, call the + /// ExtEscape function with the following parameters. + /// + /// + /// The PASSTHROUGH printer escape function is supported by PostScript drivers in GDI-centric mode or compatibility mode, but + /// not in PostScript-centric mode. Drivers in PostScript-centric mode can use the POSTSCRIPT_PASSTHROUGH escape function. To set a + /// PostScript driver mode, call the POSTSCRIPT_IDENTIFY escape function. + /// + /// + /// For PASSTHROUGH data sent by EPSPRINTING or PostScript-centric applications, the PostScript driver will not make any + /// modifications. For PASSTHROUGH data sent by other applications, if the PostScript driver is using BCP (Binary Communication + /// Protocol) or TBCP (Tagged Binary Communication Protocol) output protocol, the driver does the appropriate BCP or TBCP quoting on + /// special characters, as described in "Adobe Serial and Parallel Communications Protocols Specification." This means that the + /// application should send either ASCII or pure binary PASSTHROUGH data. + /// + /// + /// The POSTSCRIPT_DATA printer escape function sends data directly to a printer driver. To perform this operation, call the + /// ExtEscape function with the following parameters. + /// + /// + /// The POSTSCRIPT_DATA function is identical to the PASSTHROUGH escape function except that it is supported by PostScript drivers + /// in compatibility mode only. It is not supported by PostScript drivers in PostScript-centric mode or in GDI-centric mode. + /// + /// + /// Drivers in PostScript-centric mode can use the POSTSCRIPT_PASSTHROUGH escape function, and drivers in GDI-centric mode can use + /// the PASSTHROUGH escape function. To set a PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. + /// + /// The POSTSCRIPT_IDENTIFY printer escape function sets a PostScript driver to GDI-centric mode or PostScript-centric mode. + /// + /// To put the driver in GDI-centric or PostScript-centric modes, first call the QUERYESCSUPPORT printer escape function to + /// determine whether the driver supports the POSTSCRIPT_IDENTIFY printer escape function. If so, you can assume the driver is + /// PSCRIPT 5.0. Then, before you call any other printer escape function, you must call POSTSCRIPT_IDENTIFY and specify + /// either PSIDENT_GDICENTRIC or PSIDENT_PSCENTRIC. You must call the QUERYESCSUPPORT and + /// POSTSCRIPT_IDENTIFY printer escape functions before calling any other printer escape function. + /// + /// + /// Note After the PostScript driver is set to GDI-centric mode or PostScript-centric mode, you will not be allowed to call + /// the POSTSCRIPT_IDENTIFY printer escape function anymore. + /// + /// + /// If you do not use the POSTSCRIPT_IDENTIFY printer escape function, the PostScript driver is in compatibility mode and provides + /// identical support for the PASSTHROUGH, POSTSCRIPT_PASSTHROUGH, and POSTSCRIPT_DATA printer escape functions. + /// + /// + /// For PostScript drivers that support the POSTSCRIPT_PASSTHROUGH, PASSTHROUGH, and POSTSCRIPT_PASSTHROUGH printer escape + /// functions are identical. + /// + /// + /// In PostScript-centric mode, the application is responsible for all PostScript output that marks the paper using the + /// POSTSCRIPT_PASSTHROUGH escape function. GDI functions are not allowed. The driver is responsible for the overall document + /// structure and printer control settings. The application can use the POSTSCRIPT_INJECTION printer escape function to inject a + /// block of raw data (including DSC comments) into the job stream at specific places. + /// + /// + /// The POSTSCRIPT_INJECTION printer escape function inserts a block of raw data at a specified point in a PostScript job stream. + /// + /// + /// A PostScript driver supports this escape function in GDI-centric mode or PostScript-centric mode support, but not in + /// compatibility mode. + /// + /// To set the PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. + /// To perform this operation, call the ExtEscape function with the following parameters. + /// + /// The driver internally caches the injection data and emits it at appropriate points in the output. The cached information is + /// flushed when it is no longer needed. At the latest, it is flushed after the EndDoc call. + /// + /// + /// In GDI-centric mode, the application can only inject valid DSC block data by using the POSTSCRIPT_INJECTION printer escape + /// function. A valid DSC block must satisfy all of the following conditions: + /// + /// + /// + /// It consists of an integral sequence of "lines." + /// + /// + /// Each "line" must begin with "%%". + /// + /// + /// + /// Each "line" except the last line must end with <CR>, <LF>, or <CR><LF> except for the last line. If the + /// last line does not end with <CR>, <LF>, or <CR><LF>, the driver appends <CR><LF> after the + /// last byte of the injection data. + /// + /// + /// + /// Each "line" must be 255 bytes or less including the "%%" but not counting the <CR>/<LF> line termination. + /// + /// + /// The POSTSCRIPT_PASSTHROUGH printer escape function sends data directly to a PostScript printer driver. + /// + /// A PostScript driver supports this escape function when in PostScript-centric mode or in compatibility mode, but not in + /// GDI-centric mode. + /// + /// To set the PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. + /// The QUERYESCSUPPORT printer escape function checks the implementation of a printer escape function. + /// + /// The SPCLPASSTHROUGH2 printer escape function allows applications that print to PostScript devices using EPSPRINTING to include + /// private PostScript procedures and other resources at the document-level save context. + /// + /// + /// This escape is supported only for backward compatibility with Adobe Acrobat. Other applications should not use this obsolete escape. + /// + /// + /// The application must call this escape before calling StartDoc so that the driver will cache the data for insertion at the + /// correct point in the PostScript stream. If this escape is supported, the driver will also allow escape DOWNLOADFACE calls + /// prior to StartDoc. The driver internally caches the data to be inserted and the data required by any escape + /// DOWNLOADFACE calls prior to StartDoc and emits them all immediately before %%EndProlog. The sequence of + /// SPCLPASSTHROUGH2 and DOWNLOADFACE calls will be preserved in the order their data is passed in, that is, a later call + /// results in data output after an earlier call's data. The driver will consider fonts downloaded by pre- StartDoc escape + /// DOWNLOADFACE calls as unavailable for removal during the scope of the job. + /// + /// + /// This escape is not recorded in EMF files by the operating system, therefore applications must ensure that EMF recording is + /// turned off for those jobs using the escape. + /// + /// Examples + /// For an example, see Sizing a JPEG or PNG Image. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-extescape int ExtEscape( HDC hdc, int iEscape, int cjInput, + // LPCSTR lpInData, int cjOutput, LPSTR lpOutData ); + [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("wingdi.h", MSDNShortId = "5ca74f61-75dd-4a8c-9f0f-9c1b4719c75f")] + public static extern int ExtEscape(HDC hdc, EscapeFunction iEscape, int cjInput, [In] IntPtr lpInData, int cjOutput, [Out] IntPtr lpOutData); + + /// + /// The SetAbortProc function sets the application-defined abort function that allows a print job to be canceled during spooling. + /// + /// Handle to the device context for the print job. + /// + /// Pointer to the application-defined abort function. For more information about the callback function, see the AbortProc callback function. + /// + /// + /// If the function succeeds, the return value is greater than zero. + /// If the function fails, the return value is SP_ERROR. + /// + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// Examples + /// For an example, see How to Collect Print Job Information from the User. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setabortproc int SetAbortProc( HDC hdc, ABORTPROC proc ); + [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("wingdi.h", MSDNShortId = "5b6333fc-f1c3-4c76-906c-0fd13bb73953")] + public static extern int SetAbortProc(HDC hdc, AbortProc proc); + + /// The StartDoc function starts a print job. + /// A handle to the device context for the print job. + /// A pointer to a DOCINFO structure containing the name of the document file and the name of the output file. + /// + /// If the function succeeds, the return value is greater than zero. This value is the print job identifier for the document. + /// If the function fails, the return value is less than or equal to zero. + /// + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// + /// Applications should call the StartDoc function immediately before beginning a print job. Using this function ensures that + /// multipage documents are not interspersed with other print jobs. + /// + /// + /// Applications can use the value returned by StartDoc to retrieve or set the priority of a print job. Call the GetJob or + /// SetJob function and supply this value as one of the required arguments. + /// + /// Examples + /// For a sample program that uses this function, see How To: Print Using the GDI Print API. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-startdoca int StartDocA( HDC hdc, const DOCINFOA *lpdi ); + [DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("wingdi.h", MSDNShortId = "53143463-b9fc-4378-aea9-da6c73a7cd03")] + public static extern int StartDoc(HDC hdc, in DOCINFO lpdi); + + /// The StartPage function prepares the printer driver to accept data. + /// A handle to the device context for the print job. + /// + /// If the function succeeds, the return value is greater than zero. + /// If the function fails, the return value is less than or equal to zero. + /// + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// + /// The system disables the ResetDC function between calls to the StartPage and EndPage functions. This means that you cannot + /// change the device mode except at page boundaries. After calling EndPage, you can call ResetDC to change the device + /// mode, if necessary. Note that a call to ResetDC resets all device context attributes back to default values. + /// + /// + /// Neither EndPage nor StartPage resets the device context attributes. Device context attributes remain constant across + /// subsequent pages. You do not need to re-select objects and set up the mapping mode again before printing the next page; however, + /// doing so will produce the same results and reduce code differences between versions of Windows. + /// + /// Examples + /// For a sample program that uses this function, see How To: Print Using the GDI Print API. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-startpage int StartPage( HDC hdc ); + [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("wingdi.h", MSDNShortId = "b2bc0593-5eaf-40af-aa38-fbdfa1ea5f76")] + public static extern int StartPage(HDC hdc); + + /// + /// The DOCINFO structure contains the input and output file names and other information used by the StartDoc function. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-docinfoa typedef struct _DOCINFOA { int cbSize; LPCSTR + // lpszDocName; LPCSTR lpszOutput; LPCSTR lpszDatatype; DWORD fwType; } DOCINFOA, *LPDOCINFOA; + [PInvokeData("wingdi.h", MSDNShortId = "329bf0d9-399b-4f64-a029-361ef7558aeb")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct DOCINFO + { + /// The size, in bytes, of the structure. + public int cbSize; + + /// Pointer to a null-terminated string that specifies the name of the document. + [MarshalAs(UnmanagedType.LPTStr)] + public string lpszDocName; + + /// + /// Pointer to a null-terminated string that specifies the name of an output file. If this pointer is NULL, the output + /// will be sent to the device identified by the device context handle that was passed to the StartDoc function. + /// + [MarshalAs(UnmanagedType.LPTStr)] + public string lpszOutput; + + /// + /// Pointer to a null-terminated string that specifies the type of data used to record the print job. The legal values for this + /// member can be found by calling EnumPrintProcessorDatatypes and can include such values as raw, emf, or XPS_PASS. This member + /// can be NULL. Note that the requested data type might be ignored. + /// + [MarshalAs(UnmanagedType.LPTStr)] + public string lpszDatatype; + + /// + /// Specifies additional information about the print job. This member must be zero or one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// DI_APPBANDING + /// Applications that use banding should set this flag for optimal performance during printing. + /// + /// + /// DI_ROPS_READ_DESTINATION + /// The application will use raster operations that involve reading from the destination surface. + /// + /// + /// + public DI fwType; + } + + /// The DRAWPATRECT structure defines a rectangle to be created. + /// This structure is used with the DRAWPATTERNRECT printer escape. + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-drawpatrect typedef struct _DRAWPATRECT { POINT ptPosition; + // POINT ptSize; WORD wStyle; WORD wPattern; } DRAWPATRECT, *PDRAWPATRECT; + [PInvokeData("wingdi.h", MSDNShortId = "8b374a0e-8ad0-40d4-a082-e90aff6336ba")] + [StructLayout(LayoutKind.Sequential)] + public struct DRAWPATRECT + { + /// The upper-left corner of the rectangle, in logical units. + public Point ptPosition; + + /// The lower-right corner of the rectangle, in logical units. + public Point ptSize; + + /// + /// The style of the rectangle. It can be one of the following. + /// + /// + /// Value + /// Meaning + /// + /// + /// 0 + /// Black rectangle. + /// + /// + /// 1 + /// White rectangle. + /// + /// + /// 2 + /// Gray rectangle. Used with wPattern. + /// + /// + /// + public ushort wStyle; + + /// + /// Amount of grayness of the rectangle, as a percentage (0-100). A value of 0 means a white rectangle and 100 means a black + /// rectangle. This is only used when wStyle is 2. + /// + public ushort wPattern; + } + + /// + /// The PSFEATURE_CUSTPAPER structure contains information about a custom paper size for a PostScript driver. This structure + /// is used with the GET_PS_FEATURESETTING printer escape function. + /// + /// + /// For the semantics of the lOrientation, lWidth, lHeight, lWidthOffset, and lHeightOffset + /// members, please refer to "Custom Page Size Parameters" in "PostScript Printer Description File Format Specification" v.4.3. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-psfeature_custpaper typedef struct _PSFEATURE_CUSTPAPER { + // LONG lOrientation; LONG lWidth; LONG lHeight; LONG lWidthOffset; LONG lHeightOffset; } PSFEATURE_CUSTPAPER, *PPSFEATURE_CUSTPAPER; + [PInvokeData("wingdi.h", MSDNShortId = "3858154c-425f-4333-a637-6d977caf7290")] + [StructLayout(LayoutKind.Sequential)] + public struct PSFEATURE_CUSTPAPER + { + /// + /// Indicates the custom paper orientation. This member can be 0 to 3 if custom page size is selected. Otherwise, it is 1 and + /// all other structure members are zero + /// + public int lOrientation; + + /// Custom page width, in points. + public int lWidth; + + /// Custom page height, in points. + public int lHeight; + + /// Custom page width offset, in points. + public int lWidthOffset; + + /// Custom page height offset, in points. + public int lHeightOffset; + } + + /// + /// The PSFEATURE_OUTPUT structure contains information about PostScript driver output options. This structure is used with + /// the GET_PS_FEATURESETTING printer escape function. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-psfeature_output typedef struct _PSFEATURE_OUTPUT { BOOL + // bPageIndependent; BOOL bSetPageDevice; } PSFEATURE_OUTPUT, *PPSFEATURE_OUTPUT; + [PInvokeData("wingdi.h", MSDNShortId = "4ff96d45-e70e-4d80-9bab-dd1d67aee8f3")] + [StructLayout(LayoutKind.Sequential)] + public struct PSFEATURE_OUTPUT + { + /// TRUE if PostScript output is page-independent or FALSE if PostScript output is page-dependent. + [MarshalAs(UnmanagedType.Bool)] public bool bPageIndependent; + + /// + /// TRUE if printer feature code (setpagedevice's) is included or FALSE if all printer feature code is suppressed. + /// + [MarshalAs(UnmanagedType.Bool)] public bool bSetPageDevice; + } + + /// + /// The PSINJECTDATA structure is a header for the input buffer used with the POSTSCRIPT_INJECTION printer escape function. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-psinjectdata typedef struct _PSINJECTDATA { DWORD DataBytes; + // WORD InjectionPoint; WORD PageNumber; } PSINJECTDATA, *PPSINJECTDATA; + [PInvokeData("wingdi.h", MSDNShortId = "f42c8f69-7fe9-4740-b295-32ef2a5b714c")] + [StructLayout(LayoutKind.Sequential)] + public struct PSINJECTDATA + { + /// + /// The number of bytes of raw data to be injected. The raw data begins immediately following this structure. This size does not + /// include the size of the PSINJECTDATA structure. + /// + public uint DataBytes; + + /// + /// Specifies where to inject the raw data in the PostScript output. This member can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// PSINJECT_BEGINSTREAM + /// Before the first byte of job stream. + /// + /// + /// PSINJECT_PSADOBE + /// Before %!PS-Adobe. + /// + /// + /// PSINJECT_PAGESATEND + /// Replaces driver's %%Pages (atend). + /// + /// + /// PSINJECT_PAGES + /// Replaces driver's %%Pages nnn. + /// + /// + /// PSINJECT_DOCNEEDEDRES + /// After %%DocumentNeededResources. + /// + /// + /// PSINJECT_DOCSUPPLIEDRES + /// After %%DocumentSuppliedResources. + /// + /// + /// PSINJECT_PAGEORDER + /// Replaces driver's %%PageOrder. + /// + /// + /// PSINJECT_ORIENTATION + /// Replaces driver's %%Orientation. + /// + /// + /// PSINJECT_BOUNDINGBOX + /// Replaces driver's %%BoundingBox. + /// + /// + /// PSINJECT_DOCUMENTPROCESSCOLORS + /// Replaces driver's %%DocumentProcessColors <color>. + /// + /// + /// PSINJECT_COMMENTS + /// Before %%EndComments. + /// + /// + /// PSINJECT_BEGINDEFAULTS + /// After %%BeginDefaults. + /// + /// + /// PSINJECT_ENDDEFAULTS + /// Before %%EndDefaults. + /// + /// + /// PSINJECT_BEGINPROLOG + /// After %%BeginProlog. + /// + /// + /// PSINJECT_ENDPROLOG + /// Before %%EndProlog. + /// + /// + /// PSINJECT_BEGINSETUP + /// After %%BeginSetup. + /// + /// + /// PSINJECT_ENDSETUP + /// Before %%EndSetup. + /// + /// + /// PSINJECT_TRAILER + /// After %%Trailer + /// + /// + /// PSINJECT_EOF + /// After %%EOF + /// + /// + /// PSINJECT_ENDSTREAM + /// After the last byte of job stream + /// + /// + /// PSINJECT_DOCUMENTPROCESSCOLORSATEND + /// Replaces driver's %%DocumentProcessColors (atend) + /// + /// + /// Page level injection points + /// + /// + /// PSINJECT_PAGENUMBER + /// Replaces driver's %%Page + /// + /// + /// PSINJECT_BEGINPAGESETUP + /// After %%BeginPageSetup + /// + /// + /// PSINJECT_ENDPAGESETUP + /// Before %%EndPageSetup + /// + /// + /// PSINJECT_PAGETRAILER + /// After %%PageTrailer + /// + /// + /// PSINJECT_PLATECOLOR + /// Replace driver's %%PlateColor: <color> + /// + /// + /// PSINJECT_SHOWPAGE + /// Before showpage operator + /// + /// + /// PSINJECT_PAGEBBOX + /// Replaces driver's %%PageBoundingBox + /// + /// + /// PSINJECT_ENDPAGECOMMENTS + /// Before %%EndPageComments + /// + /// + /// PSINJECT_VMSAVE + /// Before save operator + /// + /// + /// PSINJECT_VMRESTORE + /// After restore operator + /// + /// + /// + public PSINJECT InjectionPoint; + + /// + /// The page number (starting from 1) to which the injection data is applied. Specify zero to apply the injection data to all + /// pages. This member is meaningful only for page level injection points starting from PSINJECT_PAGENUMBER. For other injection + /// points, set PageNumber to zero. + /// + public ushort PageNumber; + } } } \ No newline at end of file diff --git a/PInvoke/Printing/WinSpool.Enums.cs b/PInvoke/Printing/WinSpool.Enums.cs index 004b4aa1..3e0cc558 100644 --- a/PInvoke/Printing/WinSpool.Enums.cs +++ b/PInvoke/Printing/WinSpool.Enums.cs @@ -15,55 +15,293 @@ namespace Vanara.PInvoke { /// Printing-specific authorization to cancel, pause, resume, or restart the job ([MS-DTYP] ACCESS_MASK Bit 27). JOB_ACCESS_ADMINISTER = 0x00000010, + /// Printing-specific read rights for the spool file ([MS-DTYP] ACCESS_MASK Bit 26).<127> JOB_ACCESS_READ = 0x00000020, - /// Access rights for jobs combining RC (Read Control) of ACCESS_MASK with printing-specific JOB_ACCESS_ADMINISTER. - /// This value MUST NOT be passed over the wire. If it is, the server SHOULD return ERROR_ACCESS_DENIED. + + /// + /// Access rights for jobs combining RC (Read Control) of ACCESS_MASK with printing-specific JOB_ACCESS_ADMINISTER. + /// This value MUST NOT be passed over the wire. If it is, the server SHOULD return ERROR_ACCESS_DENIED. + /// JOB_EXECUTE = ACCESS_MASK.STANDARD_RIGHTS_EXECUTE | JOB_ACCESS_ADMINISTER, + /// Access rights for jobs combining RC (Read Control) of ACCESS_MASK with printing-specific JOB_ACCESS_READ. JOB_READ = ACCESS_MASK.STANDARD_RIGHTS_READ | JOB_ACCESS_READ, - /// Access rights for jobs combining RC (Read Control) of ACCESS_MASK with printing-specific JOB_ACCESS_ADMINISTER. - /// This value MUST NOT be passed over the wire. If it is, the server SHOULD return ERROR_ACCESS_DENIED. + + /// + /// Access rights for jobs combining RC (Read Control) of ACCESS_MASK with printing-specific JOB_ACCESS_ADMINISTER. + /// This value MUST NOT be passed over the wire. If it is, the server SHOULD return ERROR_ACCESS_DENIED. + /// JOB_WRITE = ACCESS_MASK.STANDARD_RIGHTS_WRITE | JOB_ACCESS_ADMINISTER, - /// Access rights for printers to perform all administrative tasks and basic printing operations except SYNCHRONIZE ([MS-DTYP] ACCESS_MASK Bit 'SY'). Combines STANDARD_RIGHTS_REQUIRED (ACCESS_MASK Bits 'RC', 'DE', 'WD', 'WO'), JOB_ACCESS_ADMINISTER (ACCESS_MASK Bit 27), and JOB_ACCESS_READ (ACCESS_MASK Bit 26). + + /// + /// Access rights for printers to perform all administrative tasks and basic printing operations except SYNCHRONIZE ([MS-DTYP] + /// ACCESS_MASK Bit 'SY'). Combines STANDARD_RIGHTS_REQUIRED (ACCESS_MASK Bits 'RC', 'DE', 'WD', 'WO'), JOB_ACCESS_ADMINISTER + /// (ACCESS_MASK Bit 27), and JOB_ACCESS_READ (ACCESS_MASK Bit 26). + /// JOB_ALL_ACCESS = ACCESS_MASK.STANDARD_RIGHTS_REQUIRED | JOB_ACCESS_ADMINISTER | JOB_ACCESS_READ, + /// Printing-specific access rights for printers to perform administrative tasks ([MS-DTYP] ACCESS_MASK Bit 29). PRINTER_ACCESS_ADMINISTER = 0x00000004, - /// Printing-specific access rights for printers to perform basic printing operations ([MS-DTYP] ACCESS_MASK Bit 28). + + /// + /// Printing-specific access rights for printers to perform basic printing operations ([MS-DTYP] ACCESS_MASK Bit 28). + /// PRINTER_ACCESS_USE = 0x00000008, - /// Printing-specific access rights for printers to perform printer data management operations ([MS-DTYP] ACCESS_MASK Bit 25).<128> + + /// Printing-specific access rights for printers to perform printer data management operations ([MS-DTYP] ACCESS_MASK + /// Bit 25).<128> PRINTER_ACCESS_MANAGE_LIMITED = 0x00000040, - /// Access rights for printers to perform all administrative tasks and basic printing operations except synchronization. Combines WO (Write Owner), WD (Write DACL), RC (Read Control), and DE (Delete) of ACCESS_MASK with printing-specific PRINTER_ACCESS_ADMINISTER and printing-specific PRINTER_ACCESS_USE. + + /// + /// Access rights for printers to perform all administrative tasks and basic printing operations except synchronization. + /// Combines WO (Write Owner), WD (Write DACL), RC (Read Control), and DE (Delete) of ACCESS_MASK with printing-specific + /// PRINTER_ACCESS_ADMINISTER and printing-specific PRINTER_ACCESS_USE. + /// PRINTER_ALL_ACCESS = ACCESS_MASK.STANDARD_RIGHTS_REQUIRED | PRINTER_ACCESS_ADMINISTER | PRINTER_ACCESS_USE, + /// Access rights for printers combining RC (Read Control) of ACCESS_MASK with printing-specific PRINTER_ACCESS_USE. PRINTER_EXECUTE = ACCESS_MASK.STANDARD_RIGHTS_EXECUTE | PRINTER_ACCESS_USE, + /// Access rights for printers combining RC (Read Control) of ACCESS_MASK with printing-specific PRINTER_ACCESS_USE. PRINTER_READ = ACCESS_MASK.STANDARD_RIGHTS_READ | PRINTER_ACCESS_USE, + /// Access rights for printers combining RC (Read Control) of ACCESS_MASK with printing-specific PRINTER_ACCESS_USE. PRINTER_WRITE = ACCESS_MASK.STANDARD_RIGHTS_WRITE | PRINTER_ACCESS_USE, + /// Printing-specific access rights to administer print servers ([MS-DTYP] ACCESS_MASK Bit 31). SERVER_ACCESS_ADMINISTER = 0x00000001, + /// Printing-specific access rights to enumerate print servers ([MS-DTYP] ACCESS_MASK Bit 30). SERVER_ACCESS_ENUMERATE = 0x00000002, - /// Access rights for print servers to perform all administrative tasks and basic printing operations except synchronization. Combines WO (Write Owner), WD (Write DACL), RC (Read Control), and DE (Delete) of ACCESS_MASK with printing-specific SERVER_ACCESS_ADMINISTER and printing-specific SERVER_ACCESS_ENUMERATE. + + /// + /// Access rights for print servers to perform all administrative tasks and basic printing operations except synchronization. + /// Combines WO (Write Owner), WD (Write DACL), RC (Read Control), and DE (Delete) of ACCESS_MASK with printing-specific + /// SERVER_ACCESS_ADMINISTER and printing-specific SERVER_ACCESS_ENUMERATE. + /// SERVER_ALL_ACCESS = ACCESS_MASK.STANDARD_RIGHTS_REQUIRED | SERVER_ACCESS_ADMINISTER | SERVER_ACCESS_ENUMERATE, + /// Access rights for print servers combining RC (Read Control) of ACCESS_MASK with printing-specific SERVER_ACCESS_ENUMERATE. SERVER_EXECUTE = ACCESS_MASK.STANDARD_RIGHTS_EXECUTE | SERVER_ACCESS_ENUMERATE, + /// Access rights for print servers combining RC (Read Control) of ACCESS_MASK with printing-specific SERVER_ACCESS_ENUMERATE. SERVER_READ = ACCESS_MASK.STANDARD_RIGHTS_READ | SERVER_ACCESS_ENUMERATE, - /// Access rights for print servers combining RC (Read Control) of ACCESS_MASK with printing-specific SERVER_ACCESS_ADMINISTER and printing-specific SERVER_ACCESS_ENUMERATE. + + /// + /// Access rights for print servers combining RC (Read Control) of ACCESS_MASK with printing-specific SERVER_ACCESS_ADMINISTER + /// and printing-specific SERVER_ACCESS_ENUMERATE. + /// SERVER_WRITE = ACCESS_MASK.STANDARD_RIGHTS_WRITE | SERVER_ACCESS_ADMINISTER | SERVER_ACCESS_ENUMERATE, } - /// Specifies additional information about the print job. - [PInvokeData("wingdi.h", MSDNShortId = "329bf0d9-399b-4f64-a029-361ef7558aeb")] - public enum DI + /// The capabilities to be queried. + [PInvokeData("wingdi.h", MSDNShortId = "d7f63ef7-0a2e-47c3-9e81-6e8a6dffe9af")] + public enum DC : uint { - /// Applications that use banding should set this flag for optimal performance during printing. - DI_APPBANDING = 0x00000001, + /// + /// Returns the dmFields member of the printer driver's DEVMODE structure. The dmFields member indicates which members in the + /// device-independent portion of the structure are supported by the printer driver. + /// + DC_FIELDS = 1, - /// The application will use raster operations that involve reading from the destination surface. - DI_ROPS_READ_DESTINATION = 0x00000002 + /// + /// Retrieves a list of supported paper sizes. The pOutput buffer receives an array of WORD values that indicate the available + /// paper sizes for the printer. The return value indicates the number of entries in the array. For a list of the possible array + /// values, see the description of the dmPaperSize member of the DEVMODE structure. If pOutput is NULL, the return value + /// indicates the required number of entries in the array. + /// + DC_PAPERS = 2, + + /// + /// Retrieves the dimensions, in tenths of a millimeter, of each supported paper size. The pOutput buffer receives an array of + /// POINT structures. Each structure contains the width (x-dimension) and length (y-dimension) of a paper size as if the paper + /// were in the DMORIENT_PORTRAIT orientation. The return value indicates the number of entries in the array. + /// + DC_PAPERSIZE = 3, + + /// + /// Returns the minimum paper size that the dmPaperLength and dmPaperWidth members of the printer driver's DEVMODE structure can + /// specify. The LOWORD of the return value contains the minimum dmPaperWidth value, and the HIWORD contains the minimum + /// dmPaperLength value. + /// + DC_MINEXTENT = 4, + + /// + /// Returns the maximum paper size that the dmPaperLength and dmPaperWidth members of the printer driver's DEVMODE structure can + /// specify. The LOWORD of the return value contains the maximum dmPaperWidth value, and the HIWORD contains the maximum + /// dmPaperLength value. + /// + DC_MAXEXTENT = 5, + + /// + /// Retrieves a list of available paper bins. The pOutput buffer receives an array of WORD values that indicate the available + /// paper sources for the printer. The return value indicates the number of entries in the array. For a list of the possible + /// array values, see the description of the dmDefaultSource member of the DEVMODE structure. If pOutput is NULL, the return + /// value indicates the required number of entries in the array. + /// + DC_BINS = 6, + + /// + /// If the printer supports duplex printing, the return value is 1; otherwise, the return value is zero. The pOutput parameter + /// is not used. + /// + DC_DUPLEX = 7, + + /// Returns the dmSize member of the printer driver's DEVMODE structure. + DC_SIZE = 8, + + /// + /// Returns the number of bytes required for the device-specific portion of the DEVMODE structure for the printer driver. + /// + DC_EXTRA = 9, + + /// Returns the specification version to which the printer driver conforms. + DC_VERSION = 10, + + /// Returns the version number of the printer driver. + DC_DRIVER = 11, + + /// + /// Retrieves the names of the printer's paper bins. The pOutput buffer receives an array of string buffers. Each string buffer + /// is 24 characters long and contains the name of a paper bin. The return value indicates the number of entries in the array. + /// The name strings are null-terminated unless the name is 24 characters long. If pOutput is NULL, the return value is the + /// number of bin entries required. + /// + DC_BINNAMES = 12, + + /// + /// Retrieves a list of the resolutions supported by the printer. The pOutput buffer receives an array of LONG values. For each + /// supported resolution, the array contains a pair of LONG values that specify the x and y dimensions of the resolution, in + /// dots per inch. The return value indicates the number of supported resolutions. If pOutput is NULL, the return value + /// indicates the number of supported resolutions. + /// + DC_ENUMRESOLUTIONS = 13, + + /// + /// Retrieves the names of any additional files that need to be loaded when a driver is installed. The pOutput buffer receives + /// an array of string buffers. Each string buffer is 64 characters long and contains the name of a file. The return value + /// indicates the number of entries in the array. The name strings are null-terminated unless the name is 64 characters long. If + /// pOutput is NULL, the return value is the number of files. + /// + DC_FILEDEPENDENCIES = 14, + + /// + /// Retrieves the abilities of the driver to use TrueType fonts. For DC_TRUETYPE, the pOutput parameter should be NULL. The + /// return value can be one or more of the following: DCTT_BITMAP Device can print TrueType fonts as graphics. DCTT_DOWNLOAD + /// Device can download TrueType fonts. DCTT_SUBDEV Device can substitute device fonts for TrueType fonts. + /// + DC_TRUETYPE = 15, + + /// + /// Retrieves a list of supported paper names (for example, Letter or Legal). The pOutput buffer receives an array of string + /// buffers. Each string buffer is 64 characters long and contains the name of a paper form. The return value indicates the + /// number of entries in the array. The name strings are null-terminated unless the name is 64 characters long. If pOutput is + /// NULL, the return value is the number of paper forms. + /// + DC_PAPERNAMES = 16, + + /// + /// Returns the relationship between portrait and landscape orientations for a device, in terms of the number of degrees that + /// portrait orientation is rotated counterclockwise to produce landscape orientation. The return value can be one of the + /// following: 0 No landscape orientation. 90 Portrait is rotated 90 degrees to produce landscape. 270 Portrait is rotated 270 + /// degrees to produce landscape. + /// + DC_ORIENTATION = 17, + + /// Returns the number of copies the device can print. + DC_COPIES = 18, + + /// Not used for NT-based operating systems. + DC_BINADJUST = 19, + + /// Not used for NT-based operating systems. + DC_EMF_COMPLIANT = 20, + + /// Not used for NT-based operating systems. + DC_DATATYPE_PRODUCED = 21, + + /// + /// If the printer supports collating, the return value is 1; otherwise, the return value is zero. The pOutput parameter is not used. + /// + DC_COLLATE = 22, + + /// Not used for NT-based operating systems. + DC_MANUFACTURER = 23, + + /// Not used for NT-based operating systems. + DC_MODEL = 24, + + /// + /// Retrieves a list of printer description languages supported by the printer. The pOutput buffer receives an array of string + /// buffers. Each buffer is 32 characters long and contains the name of a printer description language. The return value + /// indicates the number of entries in the array. The name strings are null-terminated unless the name is 32 characters long. If + /// pOutput is NULL, the return value indicates the required number of array entries. + /// + DC_PERSONALITY = 25, + + /// + /// The return value indicates the printer's print rate. The value returned for DC_PRINTRATEUNIT indicates the units of the + /// DC_PRINTRATE value. The pOutput parameter is not used. + /// + DC_PRINTRATE = 26, + + /// + /// The return value is one of the following values that indicate the print rate units for the value returned for the + /// DC_PRINTRATE flag. The pOutput parameter is not used. PRINTRATEUNIT_CPS Characters per second. PRINTRATEUNIT_IPM Inches per + /// minute. PRINTRATEUNIT_LPM Lines per minute. PRINTRATEUNIT_PPM Pages per minute. + /// + DC_PRINTRATEUNIT = 27, + + /// The return value is the amount of available printer memory, in kilobytes. The pOutput parameter is not used. + DC_PRINTERMEM = 28, + + /// + /// Retrieves the names of the paper forms that are currently available for use. The pOutput buffer receives an array of string + /// buffers. Each string buffer is 64 characters long and contains the name of a paper form. The return value indicates the + /// number of entries in the array. The name strings are null-terminated unless the name is 64 characters long. If pOutput is + /// NULL, the return value is the number of paper forms. + /// + DC_MEDIAREADY = 29, + + /// + /// If the printer supports stapling, the return value is a nonzero value; otherwise, the return value is zero. The pOutput + /// parameter is not used. + /// + DC_STAPLE = 30, + + /// The return value indicates the printer's print rate, in pages per minute. The pOutput parameter is not used. + DC_PRINTRATEPPM = 31, + + /// + /// If the printer supports color printing, the return value is 1; otherwise, the return value is zero. The pOutput parameter is + /// not used. + /// + DC_COLORDEVICE = 32, + + /// + /// Retrieves an array of integers that indicate that printer's ability to print multiple document pages per printed page. The + /// pOutput buffer receives an array of DWORD values. Each value represents a supported number of document pages per printed + /// page. The return value indicates the number of entries in the array. If pOutput is NULL, the return value indicates the + /// required number of entries in the array. + /// + DC_NUP = 33, + + /// + /// Retrieves the names of the supported media types. The pOutput buffer receives an array of string buffers. Each string buffer + /// is 64 characters long and contains the name of a supported media type. The return value indicates the number of entries in + /// the array. The strings are null-terminated unless the name is 64 characters long. If pOutput is NULL, the return value is + /// the number of media type names required. + /// + DC_MEDIATYPENAMES = 34, + + /// + /// Retrieves a list of supported media types. The pOutput buffer receives an array of DWORD values that indicate the supported + /// media types. The return value indicates the number of entries in the array. For a list of possible array values, see the + /// description of the dmMediaType member of the DEVMODE structure. If pOutput is NULL, the return value indicates the required + /// number of entries in the array. + /// + DC_MEDIATYPES = 35, } /// Device mode flags. diff --git a/PInvoke/Printing/WinSpool.Funcs.cs b/PInvoke/Printing/WinSpool.Funcs.cs index bc594e3d..4a75cb31 100644 --- a/PInvoke/Printing/WinSpool.Funcs.cs +++ b/PInvoke/Printing/WinSpool.Funcs.cs @@ -835,6 +835,302 @@ namespace Vanara.PInvoke [PInvokeData("winspool.h", MSDNShortId = "0bd81b43-5c1e-4989-8350-2ec0dc215f28")] public static extern Win32Error DeletePrinterKey(HPRINTER hPrinter, string pKeyName); + /// The DeviceCapabilities function retrieves the capabilities of a printer driver. + /// + /// A pointer to a null-terminated string that contains the name of the printer. Note that this is the name of the printer, not of + /// the printer driver. + /// + /// + /// A pointer to a null-terminated string that contains the name of the port to which the device is connected, such as LPT1. + /// + /// + /// The capabilities to be queried. This parameter can be one of the following values. + /// + /// + /// Value + /// Meaning + /// + /// + /// DC_BINNAMES + /// + /// Retrieves the names of the printer's paper bins. The pOutput buffer receives an array of string buffers. Each string buffer is + /// 24 characters long and contains the name of a paper bin. The return value indicates the number of entries in the array. The name + /// strings are null-terminated unless the name is 24 characters long. If pOutput is NULL, the return value is the number of bin + /// entries required. + /// + /// + /// + /// DC_BINS + /// + /// Retrieves a list of available paper bins. The pOutput buffer receives an array of WORD values that indicate the available paper + /// sources for the printer. The return value indicates the number of entries in the array. For a list of the possible array values, + /// see the description of the dmDefaultSource member of the DEVMODE structure. If pOutput is NULL, the return value indicates the + /// required number of entries in the array. + /// + /// + /// + /// DC_COLLATE + /// + /// If the printer supports collating, the return value is 1; otherwise, the return value is zero. The pOutput parameter is not used. + /// + /// + /// + /// DC_COLORDEVICE + /// + /// If the printer supports color printing, the return value is 1; otherwise, the return value is zero. The pOutput parameter is not used. + /// + /// + /// + /// DC_COPIES + /// Returns the number of copies the device can print. + /// + /// + /// DC_DRIVER + /// Returns the version number of the printer driver. + /// + /// + /// DC_DUPLEX + /// + /// If the printer supports duplex printing, the return value is 1; otherwise, the return value is zero. The pOutput parameter is + /// not used. + /// + /// + /// + /// DC_ENUMRESOLUTIONS + /// + /// Retrieves a list of the resolutions supported by the printer. The pOutput buffer receives an array of LONG values. For each + /// supported resolution, the array contains a pair of LONG values that specify the x and y dimensions of the resolution, in dots + /// per inch. The return value indicates the number of supported resolutions. If pOutput is NULL, the return value indicates the + /// number of supported resolutions. + /// + /// + /// + /// DC_EXTRA + /// Returns the number of bytes required for the device-specific portion of the DEVMODE structure for the printer driver. + /// + /// + /// DC_FIELDS + /// + /// Returns the dmFields member of the printer driver's DEVMODE structure. The dmFields member indicates which members in the + /// device-independent portion of the structure are supported by the printer driver. + /// + /// + /// + /// DC_FILEDEPENDENCIES + /// + /// Retrieves the names of any additional files that need to be loaded when a driver is installed. The pOutput buffer receives an + /// array of string buffers. Each string buffer is 64 characters long and contains the name of a file. The return value indicates + /// the number of entries in the array. The name strings are null-terminated unless the name is 64 characters long. If pOutput is + /// NULL, the return value is the number of files. + /// + /// + /// + /// DC_MAXEXTENT + /// + /// Returns the maximum paper size that the dmPaperLength and dmPaperWidth members of the printer driver's DEVMODE structure can + /// specify. The LOWORD of the return value contains the maximum dmPaperWidth value, and the HIWORD contains the maximum + /// dmPaperLength value. + /// + /// + /// + /// DC_MEDIAREADY + /// + /// Retrieves the names of the paper forms that are currently available for use. The pOutput buffer receives an array of string + /// buffers. Each string buffer is 64 characters long and contains the name of a paper form. The return value indicates the number + /// of entries in the array. The name strings are null-terminated unless the name is 64 characters long. If pOutput is NULL, the + /// return value is the number of paper forms. + /// + /// + /// + /// DC_MEDIATYPENAMES + /// + /// Retrieves the names of the supported media types. The pOutput buffer receives an array of string buffers. Each string buffer is + /// 64 characters long and contains the name of a supported media type. The return value indicates the number of entries in the + /// array. The strings are null-terminated unless the name is 64 characters long. If pOutput is NULL, the return value is the number + /// of media type names required. + /// + /// + /// + /// DC_MEDIATYPES + /// + /// Retrieves a list of supported media types. The pOutput buffer receives an array of DWORD values that indicate the supported + /// media types. The return value indicates the number of entries in the array. For a list of possible array values, see the + /// description of the dmMediaType member of the DEVMODE structure. If pOutput is NULL, the return value indicates the required + /// number of entries in the array. + /// + /// + /// + /// DC_MINEXTENT + /// + /// Returns the minimum paper size that the dmPaperLength and dmPaperWidth members of the printer driver's DEVMODE structure can + /// specify. The LOWORD of the return value contains the minimum dmPaperWidth value, and the HIWORD contains the minimum + /// dmPaperLength value. + /// + /// + /// + /// DC_ORIENTATION + /// + /// Returns the relationship between portrait and landscape orientations for a device, in terms of the number of degrees that + /// portrait orientation is rotated counterclockwise to produce landscape orientation. The return value can be one of the following: + /// 0 No landscape orientation. 90 Portrait is rotated 90 degrees to produce landscape. 270 Portrait is rotated 270 degrees to + /// produce landscape. + /// + /// + /// + /// DC_NUP + /// + /// Retrieves an array of integers that indicate that printer's ability to print multiple document pages per printed page. The + /// pOutput buffer receives an array of DWORD values. Each value represents a supported number of document pages per printed page. + /// The return value indicates the number of entries in the array. If pOutput is NULL, the return value indicates the required + /// number of entries in the array. + /// + /// + /// + /// DC_PAPERNAMES + /// + /// Retrieves a list of supported paper names (for example, Letter or Legal). The pOutput buffer receives an array of string + /// buffers. Each string buffer is 64 characters long and contains the name of a paper form. The return value indicates the number + /// of entries in the array. The name strings are null-terminated unless the name is 64 characters long. If pOutput is NULL, the + /// return value is the number of paper forms. + /// + /// + /// + /// DC_PAPERS + /// + /// Retrieves a list of supported paper sizes. The pOutput buffer receives an array of WORD values that indicate the available paper + /// sizes for the printer. The return value indicates the number of entries in the array. For a list of the possible array values, + /// see the description of the dmPaperSize member of the DEVMODE structure. If pOutput is NULL, the return value indicates the + /// required number of entries in the array. + /// + /// + /// + /// DC_PAPERSIZE + /// + /// Retrieves the dimensions, in tenths of a millimeter, of each supported paper size. The pOutput buffer receives an array of POINT + /// structures. Each structure contains the width (x-dimension) and length (y-dimension) of a paper size as if the paper were in the + /// DMORIENT_PORTRAIT orientation. The return value indicates the number of entries in the array. + /// + /// + /// + /// DC_PERSONALITY + /// + /// Retrieves a list of printer description languages supported by the printer. The pOutput buffer receives an array of string + /// buffers. Each buffer is 32 characters long and contains the name of a printer description language. The return value indicates + /// the number of entries in the array. The name strings are null-terminated unless the name is 32 characters long. If pOutput is + /// NULL, the return value indicates the required number of array entries. + /// + /// + /// + /// DC_PRINTERMEM + /// The return value is the amount of available printer memory, in kilobytes. The pOutput parameter is not used. + /// + /// + /// DC_PRINTRATE + /// + /// The return value indicates the printer's print rate. The value returned for DC_PRINTRATEUNIT indicates the units of the + /// DC_PRINTRATE value. The pOutput parameter is not used. + /// + /// + /// + /// DC_PRINTRATEPPM + /// The return value indicates the printer's print rate, in pages per minute. The pOutput parameter is not used. + /// + /// + /// DC_PRINTRATEUNIT + /// + /// The return value is one of the following values that indicate the print rate units for the value returned for the DC_PRINTRATE + /// flag. The pOutput parameter is not used. PRINTRATEUNIT_CPS Characters per second. PRINTRATEUNIT_IPM Inches per minute. + /// PRINTRATEUNIT_LPM Lines per minute. PRINTRATEUNIT_PPM Pages per minute. + /// + /// + /// + /// DC_SIZE + /// Returns the dmSize member of the printer driver's DEVMODE structure. + /// + /// + /// DC_STAPLE + /// + /// If the printer supports stapling, the return value is a nonzero value; otherwise, the return value is zero. The pOutput + /// parameter is not used. + /// + /// + /// + /// DC_TRUETYPE + /// + /// Retrieves the abilities of the driver to use TrueType fonts. For DC_TRUETYPE, the pOutput parameter should be NULL. The return + /// value can be one or more of the following: DCTT_BITMAP Device can print TrueType fonts as graphics. DCTT_DOWNLOAD Device can + /// download TrueType fonts. DCTT_SUBDEV Device can substitute device fonts for TrueType fonts. + /// + /// + /// + /// DC_VERSION + /// Returns the specification version to which the printer driver conforms. + /// + /// + /// + /// + /// A pointer to an array. The format of the array depends on the setting of the fwCapability parameter. See each capability above + /// to find out what is returned if pOutput is NULL. + /// + /// + /// A pointer to a DEVMODE structure. If this parameter is NULL, DeviceCapabilities retrieves the current default + /// initialization values for the specified printer driver. Otherwise, the function retrieves the values contained in the structure + /// to which pDevMode points. + /// + /// + /// + /// If the function succeeds, the return value depends on the setting of the fwCapability parameter. A return value of zero + /// generally indicates that, while the function completed successfully, there was some type of failure, such as a capability that + /// is not supported. For more details, see the descriptions for the fwCapability values. + /// + /// + /// If the function returns -1, this may mean either that the capability is not supported or there was a general function failure. + /// + /// + /// + /// + /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns + /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that + /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user + /// interface could make the application appear to be unresponsive. + /// + /// The DEVMODE structure pointed to by the pDevMode parameter may be obtained by calling the DocumentProperties function. + /// + /// If a printer driver supports custom device capabilities, the driver must call the SetPrinterData function for each custom + /// capability. The SetPrinterData function adds the appropriate printer data to the print system, which enables 32-bit + /// applications to access the custom capabilities on 64-bit Windows installations. + /// + /// + /// For each custom capability, you must first add printer data that describes the type of the capability. To do this, when you call + /// SetPrinterData, set the pValueName string to CustomDeviceCapabilityType_Xxx, where "Xxx" is the hexadecimal + /// representation of the capability. For example, you might have "CustomDeviceCapabilityType_1234". The registry data that you set + /// must be of the REG_DWORD type, and you must set its value to one of the following: + /// + /// + /// + /// 0, if the custom capability is a DWORD + /// + /// + /// 1, if the custom capability is a buffer of bytes + /// + /// + /// 2, if the custom capability is an array of items + /// + /// + /// + /// If the custom capability is an array of items, you must call SetPinterData a second time to provide information about the + /// size of an item in the array. To do this, when you call SetPinterData, the pValueName string that you provide must be + /// "CustomDeviceCapabilitySize_Xxx" where Xxx is the hexadecimal representation of the capability. For example, you might have + /// "CustomDeviceCapabilitySize_1234". The registry data that you set must be of the REG_DWORD type, and you must set its + /// value to the size in bytes of an item in the array. + /// + /// + // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-devicecapabilitiesa + // int DeviceCapabilitiesA( LPCSTR pDevice, LPCSTR pPort, WORD fwCapability, LPSTR pOutput, const DEVMODEA *pDevMode ); + [DllImport(Lib.Winspool, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("wingdi.h", MSDNShortId = "d7f63ef7-0a2e-47c3-9e81-6e8a6dffe9af")] + public static extern int DeviceCapabilities(string pDevice, [Optional] string pPort, DC fwCapability, IntPtr pOutput, in DEVMODE pDevMode); + /// The DocumentEvent function is an event handler for events associated with printing a document. /// /// A handle to a printer object. Use the OpenPrinter or AddPrinter function to retrieve a printer handle. diff --git a/PInvoke/Printing/WinSpool.Structs.cs b/PInvoke/Printing/WinSpool.Structs.cs index 1c77862b..0363f302 100644 --- a/PInvoke/Printing/WinSpool.Structs.cs +++ b/PInvoke/Printing/WinSpool.Structs.cs @@ -155,57 +155,6 @@ namespace Vanara.PInvoke public uint dwFlags; } - /// - /// The DOCINFO structure contains the input and output file names and other information used by the StartDoc function. - /// - // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-docinfoa typedef struct _DOCINFOA { int cbSize; LPCSTR - // lpszDocName; LPCSTR lpszOutput; LPCSTR lpszDatatype; DWORD fwType; } DOCINFOA, *LPDOCINFOA; - [PInvokeData("wingdi.h", MSDNShortId = "329bf0d9-399b-4f64-a029-361ef7558aeb")] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - public struct DOCINFO - { - /// The size, in bytes, of the structure. - public int cbSize; - - /// Pointer to a null-terminated string that specifies the name of the document. - [MarshalAs(UnmanagedType.LPTStr)] - public string lpszDocName; - - /// - /// Pointer to a null-terminated string that specifies the name of an output file. If this pointer is NULL, the output - /// will be sent to the device identified by the device context handle that was passed to the StartDoc function. - /// - [MarshalAs(UnmanagedType.LPTStr)] - public string lpszOutput; - - /// - /// Pointer to a null-terminated string that specifies the type of data used to record the print job. The legal values for this - /// member can be found by calling EnumPrintProcessorDatatypes and can include such values as raw, emf, or XPS_PASS. This member - /// can be NULL. Note that the requested data type might be ignored. - /// - [MarshalAs(UnmanagedType.LPTStr)] - public string lpszDatatype; - - /// - /// Specifies additional information about the print job. This member must be zero or one of the following values. - /// - /// - /// Value - /// Meaning - /// - /// - /// DI_APPBANDING - /// Applications that use banding should set this flag for optimal performance during printing. - /// - /// - /// DI_ROPS_READ_DESTINATION - /// The application will use raster operations that involve reading from the destination surface. - /// - /// - /// - public DI fwType; - } - /// The DRIVER_INFO_1 structure identifies a printer driver. // https://docs.microsoft.com/en-us/windows/win32/printdocs/driver-info-1 typedef struct _DRIVER_INFO_1 { LPTSTR pName; } // DRIVER_INFO_1, *PDRIVER_INFO_1; @@ -1992,63 +1941,6 @@ namespace Vanara.PInvoke public string pszDriverName; } - /// - /// The PRINTER_DEFAULTS structure specifies the default data type, environment, initialization data, and access rights for a printer. - /// - // https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-defaults typedef struct _PRINTER_DEFAULTS { LPTSTR pDatatype; - // LPDEVMODE pDevMode; ACCESS_MASK DesiredAccess; } PRINTER_DEFAULTS, *PPRINTER_DEFAULTS; - [PInvokeData("winspool.h", MSDNShortId = "df29c3a6-b1d1-4d40-887d-5ffc032a5871")] - public class PRINTER_DEFAULTS - { - /// Pointer to a null-terminated string that specifies the default data type for a printer. - public string pDatatype; - - /// - /// A DEVMODE structure that identifies the default environment and initialization data for a printer. - /// - public DEVMODE? pDevMode; - - /// - /// - /// Specifies desired access rights for a printer. The OpenPrinter function uses this member to set access rights to the - /// printer. These rights can affect the operation of the SetPrinter and DeletePrinter functions. The access - /// rights can be one of the following. - /// - /// - /// - /// Value - /// Meaning - /// - /// - /// PRINTER_ACCESS_ADMINISTER - /// To perform administrative tasks, such as those provided by SetPrinter. - /// - /// - /// PRINTER_ACCESS_USE - /// To perform basic printing operations. - /// - /// - /// PRINTER_ACCESS_MANAGE_LIMITED - /// - /// To perform administrative tasks, such as those provided by SetPrinter and SetPrinterData. This value is available starting - /// from Windows 8.1. - /// - /// - /// - /// PRINTER_ALL_ACCESS - /// - /// To perform all administrative tasks and basic printing operations except for SYNCHRONIZE (see Standard Access Rights ). - /// - /// - /// - /// generic security values, such as WRITE_DAC - /// To allow specific control access rights. See Standard Access Rights. - /// - /// - /// - public ACCESS_MASK DesiredAccess; - } - /// /// The PRINTER_ENUM_VALUES structure specifies the value name, type, and data for a printer configuration value returned by /// the EnumPrinterDataEx function. @@ -3677,6 +3569,61 @@ namespace Vanara.PInvoke public string pOrder; } + /// + /// The PRINTER_DEFAULTS structure specifies the default data type, environment, initialization data, and access rights for a printer. + /// + // https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-defaults typedef struct _PRINTER_DEFAULTS { LPTSTR pDatatype; + // LPDEVMODE pDevMode; ACCESS_MASK DesiredAccess; } PRINTER_DEFAULTS, *PPRINTER_DEFAULTS; + [PInvokeData("winspool.h", MSDNShortId = "df29c3a6-b1d1-4d40-887d-5ffc032a5871")] + public class PRINTER_DEFAULTS + { + /// + /// + /// Specifies desired access rights for a printer. The OpenPrinter function uses this member to set access rights to the + /// printer. These rights can affect the operation of the SetPrinter and DeletePrinter functions. The access + /// rights can be one of the following. + /// + /// + /// + /// Value + /// Meaning + /// + /// + /// PRINTER_ACCESS_ADMINISTER + /// To perform administrative tasks, such as those provided by SetPrinter. + /// + /// + /// PRINTER_ACCESS_USE + /// To perform basic printing operations. + /// + /// + /// PRINTER_ACCESS_MANAGE_LIMITED + /// + /// To perform administrative tasks, such as those provided by SetPrinter and SetPrinterData. This value is available starting + /// from Windows 8.1. + /// + /// + /// + /// PRINTER_ALL_ACCESS + /// + /// To perform all administrative tasks and basic printing operations except for SYNCHRONIZE (see Standard Access Rights ). + /// + /// + /// + /// generic security values, such as WRITE_DAC + /// To allow specific control access rights. See Standard Access Rights. + /// + /// + /// + public ACCESS_MASK DesiredAccess; + + /// Pointer to a null-terminated string that specifies the default data type for a printer. + public string pDatatype; + + /// A DEVMODE structure that identifies the default environment and initialization data for a printer. + public DEVMODE? pDevMode; + } + /// Provides a for that is disposed using . public class SafeHPRINTER : SafeHANDLE { @@ -3739,16 +3686,16 @@ namespace Vanara.PInvoke /// Initializes a new instance of the class. private SafeHSPOOLFILE() : base() { } - /// Performs an implicit conversion from to . - /// The safe handle instance. - /// The result of the conversion. - public static implicit operator HSPOOLFILE(SafeHSPOOLFILE h) => h.handle; - /// Performs an implicit conversion from to . /// The safe handle instance. /// The result of the conversion. public static implicit operator HFILE(SafeHSPOOLFILE h) => h.handle; + /// Performs an implicit conversion from to . + /// The safe handle instance. + /// The result of the conversion. + public static implicit operator HSPOOLFILE(SafeHSPOOLFILE h) => h.handle; + /// protected override bool InternalReleaseHandle() => CloseSpoolFileHandle(hPrinter, handle); }