using System;
using System.Runtime.InteropServices;
using Vanara.Extensions;
using Vanara.InteropServices;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
public static partial class WinSpool
{
///
/// The ADDJOB_INFO_1 structure identifies a print job as well as the directory and file in which an application can store
/// that job.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/addjob-info-1 typedef struct _ADDJOB_INFO_1 { LPTSTR Path; DWORD JobId;
// } ADDJOB_INFO_1, *PADDJOB_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "de915932-11a7-47e8-9be9-edab76d94189")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct ADDJOB_INFO_1
{
///
/// Pointer to a null-terminated string that contains the path and file name that the application can use to store the print job.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string Path;
/// A handle to the print job.
public uint JobId;
}
/// Represents a printer driver on which other printer drivers depend.
/// This structure can represent a manufacturer's base driver on which the drivers for various printer models are dependent.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/core-printer-driver typedef struct _CORE_PRINTER_DRIVER { GUID
// CoreDriverGUID; FILETIME ftDriverDate; DWORDLONG dwlDriverVersion; TCHAR szPackageID[MAX_PATH]; } CORE_PRINTER_DRIVER, *PCORE_PRINTER_DRIVER;
[PInvokeData("winspool.h", MSDNShortId = "b03f9ac1-7ad2-4aee-b496-e1ee15ba7d38")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct CORE_PRINTER_DRIVER
{
/// The GUID of the core printer driver.
public Guid CoreDriverGUID;
/// The date and time of the latest version of the core printer driver.
public FILETIME ftDriverDate;
/// The version ID of the latest version of the core printer driver.
public ulong dwlDriverVersion;
/// The path to the driver package that contains the core printer driver.
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szPackageID;
}
/// The DATATYPES_INFO_1 structure contains information about the data type used to record a print job.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/datatypes-info-1 typedef struct _DATATYPES_INFO_1 { LPTSTR pName; }
// DATATYPES_INFO_1, *PDATATYPES_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "6169006c-12d4-4608-865c-732f04107f9f")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DATATYPES_INFO_1
{
/// Pointer to a null-terminated string that identifies the data type used to record a print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
}
/// The DOC_INFO_1 structure describes a document that will be printed.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/doc-info-1 typedef struct _DOC_INFO_1 { LPTSTR pDocName; LPTSTR
// pOutputFile; LPTSTR pDatatype; } DOC_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "142d988b-dd74-4312-8b27-331a7ec70344")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DOC_INFO_1
{
/// Pointer to a null-terminated string that specifies the name of the document.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDocName;
///
/// Pointer to a null-terminated string that specifies the name of an output file. To print to a printer, set this to NULL.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pOutputFile;
/// Pointer to a null-terminated string that identifies the type of data used to record the document.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDatatype;
}
/// The DOC_INFO_2 structure describes a document that will be printed.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/doc-info-2 typedef struct _DOC_INFO_2 { LPTSTR pDocName; LPTSTR
// pOutputFile; LPTSTR pDatatype; DWORD dwMode; DWORD JobId; } DOC_INFO_2, *PDOC_INFO_2;
[PInvokeData("winspool.h", MSDNShortId = "d62333f3-cc39-4c9b-8fb3-02a2d24bbbad")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DOC_INFO_2
{
/// Pointer to a null-terminated string that specifies the name of the document.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDocName;
/// Pointer to a null-terminated string that specifies the name of an output file.
[MarshalAs(UnmanagedType.LPTStr)]
public string pOutputFile;
/// Pointer to a null-terminated string that identifies the type of data used to record the document.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDatatype;
///
/// Informs the print spooler of the nature of the data to follow. If this value is zero, the print spooler treats the data sent
/// by subsequent calls to WritePrinter as a normal print job (whether or not it is spooled depends on the printer
/// property). If this value is DI_CHANNEL, only a communications channel is opened. In this case, the data passed into
/// subsequent calls to WritePrinter is sent to the printer or subsequent calls to ReadPrinter retrieve data from
/// the printer. This mode remains effective until EndDoc is called.
///
public uint dwMode;
/// Reserved for internal use; should be zero.
public uint JobId;
}
/// The DOC_INFO_3 structure describes a document that will be printed.
///
/// The DI_MEMORYMAP_WRITE setting in DOC_INFO_3 is an optimization. This allows GDI to map spool files in the application
/// and speed up the recording.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/doc-info-3 typedef struct _DOC_INFO_3 { LPTSTR pDocName; LPTSTR
// pOutputFile; LPTSTR pDatatype; DWORD dwFlags; } DOC_INFO_3, *PDOC_INFO_3;
[PInvokeData("winspool.h", MSDNShortId = "6e7b6727-da04-4f67-af77-6b51c68a4eb3")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DOC_INFO_3
{
/// Pointer to a null-terminated string that specifies the name of the document.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDocName;
/// Pointer to a null-terminated string that specifies the name of an output file.
[MarshalAs(UnmanagedType.LPTStr)]
public string pOutputFile;
/// Pointer to a null-terminated string that identifies the type of data used to record the document.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDatatype;
///
/// Flags. Currently, it can be NULL or the following.
///
///
/// Flag
/// Meaning
///
/// -
/// DI_MEMORYMAP_WRITE
/// Causes StartDocPrinter to not use AddJob and ScheduleJob for local printing.
///
///
///
public uint dwFlags;
}
/// 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;
[PInvokeData("winspool.h", MSDNShortId = "9435192b-3eba-4937-8cd3-bff4e9eb84d3")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DRIVER_INFO_1
{
/// Pointer to a null-terminated string that specifies the name of a printer driver.
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
}
///
/// The DRIVER_INFO_2 structure identifies a printer driver, the driver version number, the environment for which the driver
/// was written, the name of the file in which the driver is stored, and so on.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/driver-info-2 typedef struct _DRIVER_INFO_2 { DWORD cVersion; LPTSTR
// pName; LPTSTR pEnvironment; LPTSTR pDriverPath; LPTSTR pDataFile; LPTSTR pConfigFile; } DRIVER_INFO_2, *PDRIVER_INFO_2;
[PInvokeData("winspool.h", MSDNShortId = "cca1227d-69b9-44df-8dac-384c2f8843ae")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DRIVER_INFO_2
{
/// The operating system version for which the driver was written. The supported value is 3.
public uint cVersion;
/// A pointer to a null-terminated string that specifies the name of the driver (for example, "QMS 810").
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
///
/// A pointer to a null-terminated string that specifies the environment for which the driver was written (for example, Windows
/// x86, Windows IA64, and Windows x64).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pEnvironment;
///
/// A pointer to null-terminated string that specifies a file name or full path and file name for the file that contains the
/// device driver (for example, "c:\drivers\pscript.dll").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverPath;
///
/// A pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains
/// driver data (for example, "c:\drivers\Qms810.ppd").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDataFile;
///
/// A pointer to a null-terminated string that specifies a file name or a full path and file name for the device-driver's
/// configuration .dll (for example, "c:\drivers\Pscrptui.dll").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pConfigFile;
}
/// The DRIVER_INFO_3 structure contains printer driver information.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/driver-info-3 typedef struct _DRIVER_INFO_3 { DWORD cVersion; LPTSTR
// pName; LPTSTR pEnvironment; LPTSTR pDriverPath; LPTSTR pDataFile; LPTSTR pConfigFile; LPTSTR pHelpFile; LPTSTR pDependentFiles;
// LPTSTR pMonitorName; LPTSTR pDefaultDataType; } DRIVER_INFO_3, *PDRIVER_INFO_3;
[PInvokeData("winspool.h", MSDNShortId = "ccf87319-0bcf-4f71-8de3-0190459d2b0e")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DRIVER_INFO_3
{
///
/// The operating system version for which the driver was written. The supported values are 3 and 4, which represent the V3 and
/// V4 drivers, respectively.
///
public uint cVersion;
/// A pointer to a null-terminated string that specifies the name of the driver (for example, "QMS 810").
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
///
/// A pointer to a null-terminated string that specifies the environment for which the driver was written (for example, Windows
/// x86, Windows IA64, and Windows x64).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pEnvironment;
///
/// A pointer to a null-terminated string that specifies a file name or full path and file name for the file that contains the
/// device driver (for example, "C:\DRIVERS\Pscript.dll").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverPath;
///
/// A pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains
/// driver data (for example, "C:\DRIVERS\Qms810.ppd").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDataFile;
///
/// A pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's
/// configuration dynamic-link library (for example, "C:\DRIVERS\Pscrptui.dll").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pConfigFile;
///
/// A pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's help file.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pHelpFile;
///
/// A pointer to a MultiSZ buffer that contains a sequence of null-terminated strings. Each null-terminated string in the buffer
/// contains the name of a file the driver depends on. The sequence of strings is terminated by an empty, zero-length string. If
/// pDependentFiles is not NULL and does not contain any file names, it will point to a buffer that contains two
/// empty strings.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDependentFiles;
///
/// A pointer to a null-terminated string that specifies a language monitor (for example, "PJL monitor"). This member can be
/// NULL and should be specified only for printers capable of bidirectional communication.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pMonitorName;
/// A pointer to a null-terminated string that specifies the default data type of the print job (for example, "EMF").
[MarshalAs(UnmanagedType.LPTStr)]
public string pDefaultDataType;
}
/// The DRIVER_INFO_4 structure contains printer driver information.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/driver-info-4 typedef struct _DRIVER_INFO_4 { DWORD cVersion; LPTSTR
// pName; LPTSTR pEnvironment; LPTSTR pDriverPath; LPTSTR pDataFile; LPTSTR pConfigFile; LPTSTR pHelpFile; LPTSTR pDependentFiles;
// LPTSTR pMonitorName; LPTSTR pDefaultDataType; LPTSTR pszzPreviousNames; } DRIVER_INFO_4, *PDRIVER_INFO_4;
[PInvokeData("winspool.h", MSDNShortId = "63000de6-74e7-4427-98d7-7bbd2dd61080")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DRIVER_INFO_4
{
/// The operating system version for which the driver was written. The supported value is 3.
public uint cVersion;
/// Pointer to a null-terminated string that specifies the name of the driver (for example, "QMS 810").
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
///
/// Pointer to a null-terminated string that specifies the environment for which the driver was written (for example, Windows
/// x86, Windows IA64, and Windows x64).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pEnvironment;
///
/// Pointer to a null-terminated string that specifies a file name or full path and file name for the file that contains the
/// device driver (for example, C:\DRIVERS\Pscript.dll).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverPath;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains
/// driver data (for example, C:\DRIVERS\Qms810.ppd).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDataFile;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's
/// configuration dynamic-link library (for example, C:\DRIVERS\Pscrptui.dll).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pConfigFile;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's help file.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pHelpFile;
///
/// A pointer to a MultiSZ buffer that contains a sequence of null-terminated strings. Each null-terminated string in the buffer
/// contains the name of a file the driver depends on. The sequence of strings is terminated by an empty, zero-length string. If
/// pDependentFiles is not NULL and does not contain any file names, it will point to a buffer that contains two
/// empty strings.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDependentFiles;
///
/// A pointer to a null-terminated string that specifies a language monitor (for example, PJL monitor). This member can be
/// NULL and should be specified only for printers capable of bidirectional communication.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pMonitorName;
/// A pointer to a null-terminated string that specifies the default data type of the print job (for example, EMF).
[MarshalAs(UnmanagedType.LPTStr)]
public string pDefaultDataType;
///
/// A pointer to a null-terminated string that specifies previous printer driver names that are compatible with this driver. For
/// example, OldName1\0OldName2\0\0.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszzPreviousNames;
}
/// The DRIVER_INFO_5 structure contains printer driver information.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/driver-info-5 typedef struct _DRIVER_INFO_5 { DWORD cVersion; LPTSTR
// pName; LPTSTR pEnvironment; LPTSTR pDriverPath; LPTSTR pDataFile; LPTSTR pConfigFile; DWORD dwDriverAttributes; DWORD
// dwConfigVersion; DWORD dwDriverVersion; } DRIVER_INFO_5, *PDRIVER_INFO_5;
[PInvokeData("winspool.h", MSDNShortId = "6fb63a9f-5227-46a3-97dc-8de1968e9d63")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DRIVER_INFO_5
{
/// The operating system version for which the driver was written. The supported value is 3.
public uint cVersion;
/// Pointer to a null-terminated string that specifies the name of the driver (for example, QMS 810).
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
///
/// Pointer to a null-terminated string that specifies the environment for which the driver was written (for example, Windows
/// x86, Windows IA64, and Windows x64).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pEnvironment;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains the
/// device driver (for example, C:\DRIVERS\Pscript.dll).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverPath;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains
/// driver data (for example, C:\DRIVERS\Qms810.ppd).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDataFile;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's
/// configuration dynamic-link library (for example, C:\DRIVERS\Pscrptui.dll).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pConfigFile;
/// Driver attributes, like UMPD/KMPD.
public uint dwDriverAttributes;
///
/// Number of times the configuration file for this driver has been upgraded or downgraded since the last spooler restart.
///
public uint dwConfigVersion;
/// Number of times the driver file for this driver has been upgraded or downgraded since the last spooler restart.
public uint dwDriverVersion;
}
/// The DRIVER_INFO_6 structure contains printer driver information.
///
/// The strings for these members are contained in the .inf file that is used to add the driver.
///
/// If you call AddPrinterDriver or AddPrinterDriverEx with Level not equal to 6, and then you call
/// GetPrinterDriver or EnumPrinterDrivers with Level equal to 6, the DRIVER_INFO_6 structure is returned with
/// pszMfgName, pszOEMUrl, pszHardwareID, and pszProvider set to NULL, dwlDriverVersion
/// set to 0, and ftDriverDate set to (0,0).
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/driver-info-6 typedef struct _DRIVER_INFO_6 { DWORD cVersion; LPTSTR
// pName; LPTSTR pEnvironment; LPTSTR pDriverPath; LPTSTR pDataFile; LPTSTR pConfigFile; LPTSTR pHelpFile; LPTSTR pDependentFiles;
// LPTSTR pMonitorName; LPTSTR pDefaultDataType; LPTSTR pszzPreviousNames; FILETIME ftDriverDate; DWORDLONG dwlDriverVersion; LPTSTR
// pszMfgName; LPTSTR pszOEMUrl; LPTSTR pszHardwareID; LPTSTR pszProvider; } DRIVER_INFO_6, *PDRIVER_INFO_6, *LPDRIVER_INFO_6;
[PInvokeData("winspool.h", MSDNShortId = "9771cbb5-caaa-4b7d-9a96-d24234440bac")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DRIVER_INFO_6
{
/// The operating system version for which the driver was written. The supported value is 3.
public uint cVersion;
/// Pointer to a null-terminated string that specifies the name of the driver (for example, QMS 810).
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
///
/// Pointer to a null-terminated string that specifies the environment for which the driver was written (for example, Windows NT
/// x86, Windows IA64, and Windows x64.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pEnvironment;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains the
/// device driver (for example, C:\DRIVERS\Pscript.dll).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverPath;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains
/// driver data (for example, C:\DRIVERS\Qms810.ppd).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDataFile;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's
/// configuration dynamic-link library (for example, C:\DRIVERS\Pscrptui.dll).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pConfigFile;
///
/// Pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's help
/// file (for example, C:\DRIVERS\Pscrptui.hlp).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pHelpFile;
///
/// A pointer to a MultiSZ buffer that contains a sequence of null-terminated strings. Each null-terminated string in the buffer
/// contains the name of a file the driver depends on. The sequence of strings is terminated by an empty, zero-length string. If
/// pDependentFiles is not NULL and does not contain any file names, it will point to a buffer that contains two
/// empty strings.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDependentFiles;
///
/// A pointer to a null-terminated string that specifies a language monitor (for example, "PJL monitor"). This member can be
/// NULL and should be specified only for printers capable of bidirectional communication.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pMonitorName;
/// A pointer to a null-terminated string that specifies the default data type of the print job (for example, "EMF").
[MarshalAs(UnmanagedType.LPTStr)]
public string pDefaultDataType;
///
/// A pointer to a null-terminated string that specifies previous printer driver names that are compatible with this driver. For
/// example, OldName1\0OldName2\0\0.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszzPreviousNames;
/// The date of the driver package, as coded in the driver files.
public FILETIME ftDriverDate;
/// Version number of the driver. This comes out of the version structure of the driver.
public ulong dwlDriverVersion;
/// Pointer to a null-terminated string that specifies the manufacturer's name.
[MarshalAs(UnmanagedType.LPTStr)]
public string pszMfgName;
/// Pointer to a null-terminated string that specifies the URL for the manufacturer.
[MarshalAs(UnmanagedType.LPTStr)]
public string pszOEMUrl;
/// Pointer to a null-terminated string that specifies the hardware ID for the printer driver.
[MarshalAs(UnmanagedType.LPTStr)]
public string pszHardwareID;
///
/// Pointer to a null-terminated string that specifies the provider of the printer driver (for example, "Microsoft Windows 2000")
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszProvider;
}
/// Contains printer driver information.
/// The strings for these members are contained in the .inf file that is used to add the driver.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/driver-info-8 typedef struct _DRIVER_INFO_8 { DWORD cVersion; LPTSTR
// pName; LPTSTR pEnvironment; LPTSTR pDriverPath; LPTSTR pDataFile; LPTSTR pConfigFile; LPTSTR pHelpFile; LPTSTR pDependentFiles;
// LPTSTR pMonitorName; LPTSTR pDefaultDataType; LPTSTR pszzPreviousNames; FILETIME ftDriverDate; DWORDLONG dwlDriverVersion; LPTSTR
// pszMfgName; LPTSTR pszOEMUrl; LPTSTR pszHardwareID; LPTSTR pszProvider; LPTSTR pszPrintProcessor; LPTSTR pszVendorSetup; LPTSTR
// pszzColorProfiles; LPTSTR pszInfPath; DWORD dwPrinterDriverAttributes; LPTSTR pszzCoreDriverDependencies; FILETIME
// ftMinInboxDriverVerDate; DWORDLONG dwlMinInboxDriverVerVersion; } DRIVER_INFO_8, *PDRIVER_INFO_8, *LPDRIVER_INFO_8;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct DRIVER_INFO_8
{
/// The operating system version for which the driver was written. The supported value is 3.
public uint cVersion;
/// A pointer to a null-terminated string that specifies the name of the driver (for example, QMS 810).
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
///
/// A pointer to a null-terminated string that specifies the environment for which the driver was written (for example, Windows
/// x86, Windows IA64, and Windows x64.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pEnvironment;
///
/// A pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains the
/// device driver (for example, C:\DRIVERS\Pscript.dll).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverPath;
///
/// A pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains
/// driver data (for example, C:\DRIVERS\Qms810.ppd).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDataFile;
///
/// A pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's
/// configuration dynamic-link library (for example, C:\DRIVERS\Pscrptui.dll).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pConfigFile;
///
/// A pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's help
/// file (for example, C:\DRIVERS\Pscrptui.hlp).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pHelpFile;
///
/// A pointer to a MultiSZ buffer that contains a sequence of null-terminated strings. Each null-terminated string in the buffer
/// contains the name of a file the driver depends on. The sequence of strings is terminated by an empty, zero-length string. If
/// pDependentFiles is not NULL and does not contain any file names, it will point to a buffer that contains two
/// empty strings.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDependentFiles;
///
/// A pointer to a null-terminated string that specifies a language monitor (for example, "PJL monitor"). This member can be
/// NULL and should be specified only for printers capable of bidirectional communication.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pMonitorName;
/// A pointer to a null-terminated string that specifies the default data type of the print job (for example, "EMF").
[MarshalAs(UnmanagedType.LPTStr)]
public string pDefaultDataType;
///
/// A pointer to a null-terminated string that specifies previous printer driver names that are compatible with this driver. For
/// example, OldName1\0OldName2\0\0.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszzPreviousNames;
/// The date of the driver package, as coded in the driver files.
public FILETIME ftDriverDate;
/// The version number of the driver. This comes from the version structure of the driver.
public ulong dwlDriverVersion;
/// A pointer to a null-terminated string that specifies the manufacturer's name.
[MarshalAs(UnmanagedType.LPTStr)]
public string pszMfgName;
/// A pointer to a null-terminated string that specifies the URL for the manufacturer.
[MarshalAs(UnmanagedType.LPTStr)]
public string pszOEMUrl;
/// A pointer to a null-terminated string that specifies the hardware ID for the printer driver.
[MarshalAs(UnmanagedType.LPTStr)]
public string pszHardwareID;
///
/// A pointer to a null-terminated string that specifies the provider of the printer driver (for example, "Microsoft Windows 2000").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszProvider;
/// A pointer to a null-terminated string that specifies the print processor (for example, "WinPrint").
[MarshalAs(UnmanagedType.LPTStr)]
public string pszPrintProcessor;
/// A pointer to a null-terminated string that specifies the vendor's driver setup DLL and entry point.
[MarshalAs(UnmanagedType.LPTStr)]
public string pszVendorSetup;
/// A pointer to a null-terminated string that specifies the color profiles associated with the driver.
[MarshalAs(UnmanagedType.LPTStr)]
public string pszzColorProfiles;
///
/// A pointer to a null-terminated string that specifies the path to the driver's .inf file in the driver store. (See Remarks.)
/// This must be NULL if the DRIVER_INFO_8 is being passed to AddPrinterDriver or AddPrinterDriverEx.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszInfPath;
///
///
/// Attribute flags for printer drivers. This must be 0 if the DRIVER_INFO_8 is being passed to AddPrinterDriver or
/// AddPrinterDriverEx. Otherwise, it can be any combination of the following flags:
///
///
///
/// Flag name/value
/// Meaning
/// Minimum OS
///
/// -
/// PRINTER_DRIVER_PACKAGE_AWARE 0x00000001
/// The printer driver is part of a driver package.
/// Windows Vista
///
/// -
/// PRINTER_DRIVER_XPS 0x00000002
///
/// The printer driver supports the Microsoft XPS format described in the XML Paper Specification: Overview, and also in Product
/// Behavior, section <27>.
///
/// Windows 8 Windows Server 2012
///
/// -
/// PRINTER_DRIVER_SANDBOX_ENABLED 0x00000004
///
/// The printer driver is compatible with printer driver isolation. For more information, see Product Behavior, section <28>.
///
/// Windows 7 Windows Server 2008 R2
///
/// -
/// PRINTER_DRIVER_CLASS 0x00000008
/// The printer driver is a class printer driver.
/// Windows 8 Windows Server 2012
///
/// -
/// PRINTER_DRIVER_DERIVED 0x00000010
/// The printer driver is a derived printer driver.
/// Windows 8 Windows Server 2012
///
/// -
/// PRINTER_DRIVER_NOT_SHAREABLE 0x00000020
/// Printers using this printer driver cannot be shared.
/// Windows 8 Windows Server 2012
///
/// -
/// PRINTER_DRIVER_CATEGORY_FAX 0x00000040
/// The printer driver is intended for use with fax printers.
/// Windows 8 Windows Server 2012
///
/// -
/// PRINTER_DRIVER_CATEGORY_FILE 0x00000080
/// The printer driver is intended for use with file printers.
/// Windows 8 Windows Server 2012
///
/// -
/// PRINTER_DRIVER_CATEGORY_VIRTUAL 0x00000100
/// The printer driver is intended for use with virtual printers.
/// Windows 8 Windows Server 2012
///
/// -
/// PRINTER_DRIVER_CATEGORY_SERVICE 0x00000200
/// The printer driver is intended for use with service printers.
/// Windows 8 Windows Server 2012
///
/// -
/// PRINTER_DRIVER_SOFT_RESET_REQUIRED 0x00000400
///
/// Printers that use this printer driver should follow the guidelines outlined in the USB Device Class Definition. For more
/// information, see Product Behavior, section <36>
///
/// Windows 8 Windows Server 2012
///
///
///
public PrinterDriverAttributes dwPrinterDriverAttributes;
///
/// A pointer to a null-terminated multi-string that specifies all the core printer drivers that the driver depends on. This
/// must be NULL if the DRIVER_INFO_8 is being passed to AddPrinterDriver or AddPrinterDriverEx.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszzCoreDriverDependencies;
/// The earliest allowed date of any drivers that shipped with Windows and on which this driver depends.
public FILETIME ftMinInboxDriverVerDate;
/// The earliest allowed version of any drivers that shipped with Windows and on which this driver depends.
public ulong dwlMinInboxDriverVerVersion;
}
///
/// The FORM_INFO_1 structure contains information about a print form. The information includes the print form's origin, its
/// name, its dimensions, and the dimensions of its printable area.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/form-info-1 typedef struct _FORM_INFO_1 { DWORD Flags; LPTSTR pName;
// SIZEL Size; RECTL ImageableArea; } FORM_INFO_1, *PFORM_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "1c42ea6c-82cf-463c-bc67-44a8d8c4a1e7")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct FORM_INFO_1
{
///
/// The form properties. The following values are defined.
///
///
/// Value
/// Meaning
///
/// -
/// FORM_USER
/// If this bit flag is set, the form has been defined by the user. Forms with this flag set are defined in the registry.
///
/// -
/// FORM_BUILTIN
///
/// If this bit-flag is set, the form is part of the spooler. Form definitions with this flag set do not appear in the registry.
///
///
/// -
/// FORM_PRINTER
/// If this bit flag is set, the form is associated with a certain printer, and its definition appears in the registry.
///
///
///
public FormFlags Flags;
/// Pointer to a null-terminated string that specifies the name of the form. The form name cannot exceed 31 characters.
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
/// The width and height, in thousandths of millimeters, of the form.
public SIZE Size;
/// The width and height, in thousandths of millimeters, of the form.
public RECT ImageableArea;
}
/// Contains information about a localizable print form.
///
/// On a call to AddForm or SetForm:
///
/// -
///
/// If StringType is STRING_NONE, both pMuiDll and pDisplayName must be NULL and both
/// dwResourceId and wLangId must be 0.
///
///
/// -
/// If StringType is STRING_MUIDLL, pDisplayName must be NULL and wLangId must be 0.
///
/// -
/// If StringType is STRING_LANGPAIR, pMuiDll must be NULL and dwResourceId must be 0.
///
///
/// For a FORM_INFO_2 returned by a call to GetForm or EnumForms:
///
/// -
///
/// If StringType is both STRING_MUIDLL and STRING_LANGPAIR, pMuiDll, pDisplayName, dwResourceId, and
/// wLangId will all have valid values.
///
///
/// -
///
/// If StringType is STRING_MUIDLL only, pMuiDll and dwResourceId will have valid values. pDisplayName
/// will be NULL and wLangId will be 0.
///
///
/// -
///
/// If StringType is STRING_LANGPAIR only, pDisplayName and wLangId will have valid values. pMuiDll will
/// be NULL and dwResourceId will be 0.
///
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/form-info-2 typedef struct _FORM_INFO_2 { DWORD Flags; LPTSTR pName;
// SIZEL Size; RECTL ImageableArea; LPCSTR pKeyword; DWORD StringType; LPCTSTR pMuiDll; DWORD dwResourceId; LPCTSTR pDisplayName;
// LANGID wLangId; } FORM_INFO_2, *PFORM_INFO_2;
[PInvokeData("winspool.h", MSDNShortId = "5cc11a77-2b9d-44a4-88de-6ed0b7460bc8")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct FORM_INFO_2
{
///
///
/// The form properties. The following values are defined, but only one can be set. When the FORM_INFO_2 is returned by
/// GetForm or EnumForms, Flags is set to the current value in the forms database.
///
///
///
/// Value
/// Meaning
///
/// -
/// FORM_USER
/// If this bit flag is set, the form has been defined by the user. Forms with this flag set are defined in the registry.
///
/// -
/// FORM_BUILTIN
///
/// If this bit-flag is set, the form is part of the spooler. Form definitions with this flag set do not appear in the registry.
/// Built-in forms cannot be modified, so this flag should not be set when the structure is passed to AddForm or SetForm.
///
///
/// -
/// FORM_PRINTER
/// If this bit flag is set, the form is associated with a certain printer, and its definition appears in the registry.
///
///
///
public FormFlags Flags;
/// A pointer to a null-terminated string that specifies the name of the form. The form name cannot exceed 31 characters.
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
/// The width and height of the form in thousandths of millimeters.
public SIZE Size;
/// The width and height, in thousandths of millimeters, of the area of the page on which the printer can print.
public RECT ImageableArea;
///
/// A pointer to a non-localizable string identifier of the form. When passed to AddForm or SetForm, this gives
/// the caller a means of identifying the form in all locales.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pKeyword;
///
///
/// Specifies how a localized display name for the form is obtained at runtime. The following values are defined. Only one can
/// be set in any given call to AddForm or SetForm. Both STRING_MUIDLL and STRING_LANGPAIR can be set in the
/// FORM_INFO_2 (s) returned by GetForm or EnumForms. See Remarks.
///
///
///
/// Value
/// Meaning
///
/// -
/// STRING_NONE
/// There is no localized display name.
///
/// -
/// STRING_MUIDLL
///
/// The display name is extracted from the Multilingual User Interface localized resources DLL specified in pMuiDll. The ID is
/// in the dwResourceId member.
///
///
/// -
/// STRING_LANGPAIR
/// The display name and language ID are provided directly by pDisplayName and the language is specified by wLangId.
///
///
///
public FormStringType StringType;
/// The Multilingual User Interface localized resource DLL that contains the localized display name.
[MarshalAs(UnmanagedType.LPTStr)]
public string pMuiDll;
/// The resource ID of the form's display name in pMuiDll.
public uint dwResourceId;
/// The form's display name in the language specified by wLangId.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDisplayName;
/// The language of the pDisplayName.
public ushort wLangId;
}
/// Provides a handle to a printer.
[StructLayout(LayoutKind.Sequential)]
public struct HPRINTER : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HPRINTER(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HPRINTER NULL => new HPRINTER(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HPRINTER h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HPRINTER(IntPtr h) => new HPRINTER(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HPRINTER h1, HPRINTER h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HPRINTER h1, HPRINTER h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HPRINTER h ? handle == h.handle : false;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// Provides a handle to a printer change notification.
[StructLayout(LayoutKind.Sequential)]
public struct HPRINTERCHANGENOTIFICATION : IHandle
{
private IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HPRINTERCHANGENOTIFICATION(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HPRINTERCHANGENOTIFICATION NULL => new HPRINTERCHANGENOTIFICATION(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HPRINTERCHANGENOTIFICATION h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HPRINTERCHANGENOTIFICATION(IntPtr h) => new HPRINTERCHANGENOTIFICATION(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HPRINTERCHANGENOTIFICATION h1, HPRINTERCHANGENOTIFICATION h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HPRINTERCHANGENOTIFICATION h1, HPRINTERCHANGENOTIFICATION h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HPRINTERCHANGENOTIFICATION h ? handle == h.handle : false;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
/// Provides a handle to a spool file.
[StructLayout(LayoutKind.Sequential)]
public struct HSPOOLFILE : IHandle
{
private readonly IntPtr handle;
/// Initializes a new instance of the struct.
/// An object that represents the pre-existing handle to use.
public HSPOOLFILE(IntPtr preexistingHandle) => handle = preexistingHandle;
/// Returns an invalid handle by instantiating a object with .
public static HSPOOLFILE NULL => new HSPOOLFILE(IntPtr.Zero);
/// Gets a value indicating whether this instance is a null handle.
public bool IsNull => handle == IntPtr.Zero;
/// Performs an explicit conversion from to .
/// The handle.
/// The result of the conversion.
public static explicit operator IntPtr(HSPOOLFILE h) => h.handle;
/// Performs an implicit conversion from to .
/// The pointer to a handle.
/// The result of the conversion.
public static implicit operator HSPOOLFILE(IntPtr h) => new HSPOOLFILE(h);
/// Implements the operator !=.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator !=(HSPOOLFILE h1, HSPOOLFILE h2) => !(h1 == h2);
/// Implements the operator ==.
/// The first handle.
/// The second handle.
/// The result of the operator.
public static bool operator ==(HSPOOLFILE h1, HSPOOLFILE h2) => h1.Equals(h2);
///
public override bool Equals(object obj) => obj is HSPOOLFILE h ? handle == h.handle : false;
///
public override int GetHashCode() => handle.GetHashCode();
///
public IntPtr DangerousGetHandle() => handle;
}
///
/// The JOB_INFO_1 structure specifies print-job information such as the job-identifier value, the name of the printer for
/// which the job is spooled, the name of the machine that created the print job, the name of the user that owns the print job, and
/// so on.
///
///
/// Port monitors that do not support TrueEndOfJob will set the job as JOB_STATUS_PRINTED right after the job is submitted to the printer.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/job-info-1 typedef struct _JOB_INFO_1 { DWORD JobId; LPTSTR
// pPrinterName; LPTSTR pMachineName; LPTSTR pUserName; LPTSTR pDocument; LPTSTR pDatatype; LPTSTR pStatus; DWORD Status; DWORD
// Priority; DWORD Position; DWORD TotalPages; DWORD PagesPrinted; SYSTEMTIME Submitted; } JOB_INFO_1, *PJOB_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "d42ada89-6bc7-4006-81d9-dbcc0347edd3")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct JOB_INFO_1
{
/// A job identifier.
public uint JobId;
/// A pointer to a null-terminated string that specifies the name of the printer for which the job is spooled.
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrinterName;
/// A pointer to a null-terminated string that specifies the name of the machine that created the print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pMachineName;
/// A pointer to a null-terminated string that specifies the name of the user that owns the print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pUserName;
/// A pointer to a null-terminated string that specifies the name of the print job (for example, "MS-WORD: Review.doc").
[MarshalAs(UnmanagedType.LPTStr)]
public string pDocument;
/// A pointer to a null-terminated string that specifies the type of data used to record the print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDatatype;
///
/// A pointer to a null-terminated string that specifies the status of the print job. This member should be checked prior to
/// Status and, if pStatus is NULL, the status is defined by the contents of the Status member.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pStatus;
///
///
/// The job status. The value of this member can be zero or a combination of one or more of the following values. A value of
/// zero indicates that the print queue was paused after the document finished spooling.
///
///
///
/// Value
/// Meaning
///
/// -
/// JOB_STATUS_BLOCKED_DEVQ
/// The driver cannot print the job.
///
/// -
/// JOB_STATUS_COMPLETE
/// Windows XP and later: Job is sent to the printer, but the job may not be printed yet. See Remarks for more information.
///
/// -
/// JOB_STATUS_DELETED
/// Job has been deleted.
///
/// -
/// JOB_STATUS_DELETING
/// Job is being deleted.
///
/// -
/// JOB_STATUS_ERROR
/// An error is associated with the job.
///
/// -
/// JOB_STATUS_OFFLINE
/// Printer is offline.
///
/// -
/// JOB_STATUS_PAPEROUT
/// Printer is out of paper.
///
/// -
/// JOB_STATUS_PAUSED
/// Job is paused.
///
/// -
/// JOB_STATUS_PRINTED
/// Job has printed.
///
/// -
/// JOB_STATUS_PRINTING
/// Job is printing.
///
/// -
/// JOB_STATUS_RESTART
/// Job has been restarted.
///
/// -
/// JOB_STATUS_RETAINED
///
/// Windows Vista and later: Job has been retained in the print queue and cannot be deleted. This can be caused by the
/// following: 1) The job was manually retained by a call to SetJob and the spooler is waiting for the job to be released. 2)
/// The job has not finished printing and must finish printing before it can be automatically deleted. See SetJob for more
/// information about print job commands.
///
///
/// -
/// JOB_STATUS_SPOOLING
/// Job is spooling.
///
/// -
/// JOB_STATUS_USER_INTERVENTION
/// Printer has an error that requires the user to do something.
///
///
///
public JOB_STATUS Status;
///
///
/// The job priority. This member can be one of the following values or in the range between 1 through 99 (MIN_PRIORITY through MAX_PRIORITY).
///
///
///
/// Value
/// Meaning
///
/// -
/// MIN_PRIORITY
/// Minimum priority.
///
/// -
/// MAX_PRIORITY
/// Maximum priority.
///
/// -
/// DEF_PRIORITY
/// Default priority.
///
///
///
public JOB_PRIORITY Priority;
/// The job's position in the print queue.
public uint Position;
///
/// The total number of pages that the document contains. This value may be zero if the print job does not contain page
/// delimiting information.
///
public uint TotalPages;
///
/// The number of pages that have printed. This value may be zero if the print job does not contain page delimiting information.
///
public uint PagesPrinted;
///
/// A SYSTEMTIME structure that specifies the time that this document was spooled.
///
/// This time value is in Universal Time Coordinate (UTC) format. You should convert it to a local time value before displaying
/// it. You can use the FileTimeToLocalFileTime function to perform the conversion.
///
///
public SYSTEMTIME Submitted;
}
/// The JOB_INFO_2 structure describes a full set of values associated with a job.
///
/// Port monitors that do not support TrueEndOfJob will set the job as JOB_STATUS_PRINTED right after the job is submitted to the printer.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/job-info-2 typedef struct _JOB_INFO_2 { DWORD JobId; LPTSTR
// pPrinterName; LPTSTR pMachineName; LPTSTR pUserName; LPTSTR pDocument; LPTSTR pNotifyName; LPTSTR pDatatype; LPTSTR
// pPrintProcessor; LPTSTR pParameters; LPTSTR pDriverName; LPDEVMODE pDevMode; LPTSTR pStatus; PSECURITY_DESCRIPTOR
// pSecurityDescriptor; DWORD Status; DWORD Priority; DWORD Position; DWORD StartTime; DWORD UntilTime; DWORD TotalPages; DWORD
// Size; SYSTEMTIME Submitted; DWORD Time; DWORD PagesPrinted; } JOB_INFO_2, *PJOB_INFO_2;
[PInvokeData("winspool.h", MSDNShortId = "0cc61e35-4ac9-47bd-bb0d-ff43854bdee5")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct JOB_INFO_2
{
/// A job identifier value.
public uint JobId;
/// A pointer to a null-terminated string that specifies the name of the printer for which the job is spooled.
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrinterName;
/// A pointer to a null-terminated string that specifies the name of the machine that created the print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pMachineName;
/// A pointer to a null-terminated string that specifies the name of the user who owns the print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pUserName;
/// A pointer to a null-terminated string that specifies the name of the print job (for example, "MS-WORD: Review.doc").
[MarshalAs(UnmanagedType.LPTStr)]
public string pDocument;
///
/// A pointer to a null-terminated string that specifies the name of the user who should be notified when the job has been
/// printed or when an error occurs while printing the job.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pNotifyName;
/// A pointer to a null-terminated string that specifies the type of data used to record the print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDatatype;
///
/// A pointer to a null-terminated string that specifies the name of the print processor that should be used to print the job.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrintProcessor;
/// A pointer to a null-terminated string that specifies print-processor parameters.
[MarshalAs(UnmanagedType.LPTStr)]
public string pParameters;
///
/// A pointer to a null-terminated string that specifies the name of the printer driver that should be used to process the print job.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverName;
///
/// A pointer to a DEVMODE structure that contains device-initialization and environment data for the printer driver.
///
public IntPtr pDevMode;
///
/// A pointer to a null-terminated string that specifies the status of the print job. This member should be checked prior to
/// Status and, if pStatus is NULL, the status is defined by the contents of the Status member.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pStatus;
///
/// The value of this member is NULL. Retrieval and setting of document security descriptors is not supported in this release.
///
public PSECURITY_DESCRIPTOR pSecurityDescriptor;
///
/// The job status. This member can be one or more of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// JOB_STATUS_BLOCKED_DEVQ
/// The driver cannot print the job.
///
/// -
/// JOB_STATUS_DELETED
/// Job has been deleted.
///
/// -
/// JOB_STATUS_DELETING
/// Job is being deleted.
///
/// -
/// JOB_STATUS_ERROR
/// An error is associated with the job.
///
/// -
/// JOB_STATUS_OFFLINE
/// Printer is offline.
///
/// -
/// JOB_STATUS_PAPEROUT
/// Printer is out of paper.
///
/// -
/// JOB_STATUS_PAUSED
/// Job is paused.
///
/// -
/// JOB_STATUS_PRINTED
/// Job has printed.
///
/// -
/// JOB_STATUS_PRINTING
/// Job is printing.
///
/// -
/// JOB_STATUS_RESTART
/// Job has been restarted.
///
/// -
/// JOB_STATUS_SPOOLING
/// Job is spooling.
///
/// -
/// JOB_STATUS_USER_INTERVENTION
/// Printer has an error that requires the user to do something.
///
///
/// In Windows XP and later versions of Windows, the following values can also be used:
///
///
/// Value
/// Meaning
///
/// -
/// JOB_STATUS_COMPLETE
/// The job is sent to the printer, but may not be printed yet. See Remarks for more information.
///
/// -
/// JOB_STATUS_RETAINED
/// The job has been retained in the print queue following printing.
///
///
///
public JOB_STATUS Status;
///
///
/// The job priority. This member can be one of the following values or in the range between 1 through 99 (MIN_PRIORITY through MAX_PRIORITY).
///
///
///
/// Value
/// Meaning
///
/// -
/// MIN_PRIORITY
/// Minimum priority.
///
/// -
/// MAX_PRIORITY
/// Maximum priority.
///
/// -
/// DEF_PRIORITY
/// Default priority.
///
///
///
public JOB_PRIORITY Priority;
/// The job's position in the print queue.
public uint Position;
/// The earliest time that the job can be printed.
public uint StartTime;
/// The latest time that the job can be printed.
public uint UntilTime;
///
/// The number of pages required for the job. This value may be zero if the print job does not contain page delimiting information.
///
public uint TotalPages;
/// The size, in bytes, of the job.
public uint Size;
///
/// A SYSTEMTIME structure that specifies the time when the job was submitted.
///
/// This time value is in Universal Time Coordinate (UTC) format. You should convert it to a local time value before displaying
/// it. You can use the FileTimeToLocalFileTime function to perform the conversion.
///
///
public SYSTEMTIME Submitted;
/// The total time, in milliseconds, that has elapsed since the job began printing.
public uint Time;
///
/// The number of pages that have printed. This value may be zero if the print job does not contain page delimiting information.
///
public uint PagesPrinted;
/// A DEVMODE structure that contains device-initialization and environment data for the printer driver.
public DEVMODE DevMode => pDevMode.ToStructure();
}
/// The JOB_INFO_3 structure is used to link together a set of print jobs.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/job-info-3 typedef struct _JOB_INFO_3 { DWORD JobId; DWORD NextJobId;
// DWORD Reserved; } JOB_INFO_3, *PJOB_INFO_3;
[PInvokeData("winspool.h", MSDNShortId = "a110f555-dc33-450c-ae77-ea26f0f69448")]
[StructLayout(LayoutKind.Sequential)]
public struct JOB_INFO_3
{
/// The print job identifier.
public uint JobId;
/// The print job identifier for the next print job in the linked set of print jobs.
public uint NextJobId;
/// This value is reserved for future use. You must set it to zero.
public uint Reserved;
}
///
/// Describes a full set of values associated with a job and supports large spool files with sizes expressed with 64 bits.
///
///
/// Port monitors that do not support TrueEndOfJob will set the job as JOB_STATUS_PRINTED immediately after the job is submitted to
/// the printer.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/job-info-4 typedef struct _JOB_INFO_4 { DWORD JobId; LPTSTR
// pPrinterName; LPTSTR pMachineName; LPTSTR pUserName; LPTSTR pDocument; LPTSTR pNotifyName; LPTSTR pDatatype; LPTSTR
// pPrintProcessor; LPTSTR pParameters; LPTSTR pDriverName; LPDEVMODE pDevMode; LPTSTR pStatus; PSECURITY_DESCRIPTOR
// pSecurityDescriptor; DWORD Status; DWORD Priority; DWORD Position; DWORD StartTime; DWORD UntilTime; DWORD TotalPages; DWORD
// Size; SYSTEMTIME Submitted; DWORD Time; DWORD PagesPrinted; LONG SizeHigh; } JOB_INFO_4, *PJOB_INFO_4;
[PInvokeData("winspool.h", MSDNShortId = "90932ae2-ea9e-43bc-9a1d-c68223f6d0ee")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct JOB_INFO_4
{
/// A job identifier value.
public uint JobId;
/// A pointer to a null-terminated string that specifies the name of the printer for which the job is spooled.
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrinterName;
/// A pointer to a null-terminated string that specifies the name of the machine that created the print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pMachineName;
/// A pointer to a null-terminated string that specifies the name of the user who owns the print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pUserName;
/// A pointer to a null-terminated string that specifies the name of the print job (for example, "MS-WORD: Review.doc").
[MarshalAs(UnmanagedType.LPTStr)]
public string pDocument;
///
/// A pointer to a null-terminated string that specifies the name of the user who should be notified when the job has been
/// printed, or when an error occurs while printing the job.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pNotifyName;
/// A pointer to a null-terminated string that specifies the type of data used to record the print job.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDatatype;
///
/// A pointer to a null-terminated string that specifies the name of the print processor that should be used to print the job.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrintProcessor;
/// A pointer to a null-terminated string that specifies print-processor parameters.
[MarshalAs(UnmanagedType.LPTStr)]
public string pParameters;
///
/// A pointer to a null-terminated string that specifies the name of the printer driver that should be used to process the print job.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverName;
///
/// A pointer to a DEVMODE structure that contains device-initialization and environment data for the printer driver.
///
public IntPtr pDevMode;
///
/// A pointer to a null-terminated string that specifies the status of the print job. This member should be checked prior to
/// Status and, if pStatus is NULL, the status is defined by the contents of the Status member.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pStatus;
///
/// The value of this member is NULL. Retrieval and setting of document security descriptors is not supported in this release.
///
public PSECURITY_DESCRIPTOR pSecurityDescriptor;
///
/// The job status. This member can be one or more of the following values:
///
///
/// Value
/// Meaning
///
/// -
/// JOB_STATUS_BLOCKED_DEVQ
/// The driver cannot print the job.
///
/// -
/// JOB_STATUS_DELETED
/// Job has been deleted.
///
/// -
/// JOB_STATUS_DELETING
/// Job is being deleted.
///
/// -
/// JOB_STATUS_ERROR
/// An error is associated with the job.
///
/// -
/// JOB_STATUS_OFFLINE
/// Printer is offline.
///
/// -
/// JOB_STATUS_PAPEROUT
/// Printer is out of paper.
///
/// -
/// JOB_STATUS_PAUSED
/// Job is paused.
///
/// -
/// JOB_STATUS_PRINTED
/// Job has printed.
///
/// -
/// JOB_STATUS_PRINTING
/// Job is printing.
///
/// -
/// JOB_STATUS_RESTART
/// Job has been restarted.
///
/// -
/// JOB_STATUS_SPOOLING
/// Job is spooling.
///
/// -
/// JOB_STATUS_USER_INTERVENTION
/// Printer has an error that requires the user to do something.
///
///
/// In Windows XP and later versions of Windows, the following values can also be used:
///
///
/// Value
/// Meaning
///
/// -
/// JOB_STATUS_COMPLETE
/// The job is sent to the printer, but may not be printed yet. See Remarks for more information.
///
/// -
/// JOB_STATUS_RETAINED
/// The job has been retained in the print queue following printing.
///
///
///
public JOB_STATUS Status;
///
///
/// The job priority. This member can be one of the following values, or in the range between 1 through 99 (MIN_PRIORITY through MAX_PRIORITY).
///
///
///
/// Value
/// Meaning
///
/// -
/// MIN_PRIORITY
/// Minimum priority.
///
/// -
/// MAX_PRIORITY
/// Maximum priority.
///
/// -
/// DEF_PRIORITY
/// Default priority.
///
///
///
public JOB_PRIORITY Priority;
/// The job's position in the print queue.
public uint Position;
/// The earliest time that the job can be printed.
public uint StartTime;
/// The latest time that the job can be printed.
public uint UntilTime;
///
/// The number of pages required for the job. This value may be zero if the print job does not contain page delimiting information.
///
public uint TotalPages;
/// The lower four bytes of the size, in bytes, of the job. See also the SizeHigh member below.
public uint Size;
///
/// A SYSTEMTIME structure that specifies the time when the job was submitted.
///
/// This time value is in Universal Time Coordinate (UTC) format. You should convert it to a local time value before displaying
/// it. You can use the FileTimeToLocalFileTime function to perform the conversion.
///
///
public SYSTEMTIME Submitted;
/// The total time, in milliseconds, that has elapsed since the job began printing.
public uint Time;
///
/// The number of pages that have printed. This value may be zero if the print job does not contain page delimiting information.
///
public uint PagesPrinted;
/// The higher four bytes of the size, in bytes, of the job. See also the Size member above.
public int SizeHigh;
/// A DEVMODE structure that contains device-initialization and environment data for the printer driver.
public DEVMODE DevMode => pDevMode.ToStructure();
}
/// The MONITOR_INFO_1 structure identifies an installed monitor.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/monitor-info-1 typedef struct _MONITOR_INFO_1 { LPTSTR pName; }
// MONITOR_INFO_1, *PMONITOR_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "7a4660bd-5df8-49dd-92f6-9574f451f10d")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MONITOR_INFO_1
{
/// A pointer to a null-terminated string that identifies an installed monitor.
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
}
/// The MONITOR_INFO_2 structure identifies a monitor.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/monitor-info-2 typedef struct _MONITOR_INFO_2 { LPTSTR pName; LPTSTR
// pEnvironment; LPTSTR pDLLName; } MONITOR_INFO_2, *PMONITOR_INFO_2;
[PInvokeData("winspool.h", MSDNShortId = "4dd1ca15-6983-403e-8159-1a6d35a88162")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MONITOR_INFO_2
{
/// A pointer to a null-terminated string that is the name of the monitor.
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
///
/// A pointer to a null-terminated string that specifies the environment for which the monitor was written (for example, Windows
/// NT x86, Windows IA64, Windows x64).
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pEnvironment;
/// A pointer to a null-terminated string that is the name of the monitor DLL.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDLLName;
}
/// The PORT_INFO_1 structure identifies a supported printer port.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/port-info-1 typedef struct _PORT_INFO_1 { LPTSTR pName; } PORT_INFO_1, *PPORT_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "e474fe9c-e554-406a-a5bf-de07f9a72b32")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PORT_INFO_1
{
/// Pointer to a null-terminated string that identifies a supported printer port (for example, "LPT1:").
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
}
/// The PORT_INFO_2 structure identifies a supported printer port.
///
///
/// Use the PORT_INFO_2 structure when calling EnumPorts if there are multiple monitors installed that support the
/// same ports.
///
///
/// The fPortType member can be queried to determine information about the port. Note that port settings do not influence
/// printer attributes (as returned by the Attributes member of PRINTER_INFO_2).
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/port-info-2 typedef struct _PORT_INFO_2 { LPTSTR pPortName; LPTSTR
// pMonitorName; LPTSTR pDescription; DWORD fPortType; DWORD Reserved; } PORT_INFO_2, *PPORT_INFO_2;
[PInvokeData("winspool.h", MSDNShortId = "93675294-61d4-40e4-b84c-f252978e0285")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PORT_INFO_2
{
/// Pointer to a null-terminated string that identifies a supported printer port (for example, "LPT1:").
[MarshalAs(UnmanagedType.LPTStr)]
public string pPortName;
///
/// Pointer to a null-terminated string that identifies an installed monitor (for example, "PJL monitor"). This can be NULL.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pMonitorName;
///
/// Pointer to a null-terminated string that describes the port in more detail (for example, if pPortName is "LPT1:",
/// pDescription is "printer port"). This can be NULL.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDescription;
/// Bitmask describing the type of port. This member can be a combination of the following values:
public PORT_TYPE fPortType;
/// Reserved; must be zero.
public uint Reserved;
}
/// The PORT_INFO_3 structure specifies the status value of a printer port.
///
/// When you set a printer port status value with the severity value PORT_STATUS_TYPE_ERROR, the print spooler stops sending jobs to
/// the port. The print spooler does not resume sending jobs to the port until another SetPort call is made to clear the status.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/port-info-3 typedef struct _PORT_INFO_3 { DWORD dwStatus; LPTSTR
// pszStatus; DWORD dwSeverity; } PORT_INFO_3, *PPORT_INFO_3;
[PInvokeData("winspool.h", MSDNShortId = "0939353f-284b-4dbb-89a2-04918c934430")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PORT_INFO_3
{
///
/// The new port status value. This value is used only if the pszStatus member is NULL.
/// This member can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// 0
/// Clears the printer port status.
///
/// -
/// PORT_STATUS_OFFLINE
/// The port's printer is offline.
///
/// -
/// PORT_STATUS_PAPER_JAM
/// The port's printer has a paper jam.
///
/// -
/// PORT_STATUS_PAPER_OUT
/// The port's printer is out of paper.
///
/// -
/// PORT_STATUS_OUTPUT_BIN_FULL
/// The port's printer's output bin is full.
///
/// -
/// PORT_STATUS_PAPER_PROBLEM
/// The port's printer has a paper problem.
///
/// -
/// PORT_STATUS_NO_TONER
/// The port's printer is out of toner.
///
/// -
/// PORT_STATUS_DOOR_OPEN
/// The door of the port's printer is open.
///
/// -
/// PORT_STATUS_USER_INTERVENTION
/// The port's printer requires user intervention.
///
/// -
/// PORT_STATUS_OUT_OF_MEMORY
/// The port's printer is out of memory.
///
/// -
/// PORT_STATUS_TONER_LOW
/// The port's printer is low on toner.
///
/// -
/// PORT_STATUS_WARMING_UP
/// The port's printer is warming up.
///
/// -
/// PORT_STATUS_POWER_SAVE
/// The port's printer is in a power-conservation mode.
///
///
///
public PORT_STATUS dwStatus;
///
/// Pointer to a new printer port status value string to set. Use this member if there is no suitable status value among those
/// listed for dwStatus.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszStatus;
///
/// The severity of the port status value.
/// This member can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PORT_STATUS_TYPE_ERROR
/// The port status value indicates an error.
///
/// -
/// PORT_STATUS_TYPE_WARNING
/// The port status value is a warning.
///
/// -
/// PORT_STATUS_TYPE_INFO
/// The port status value is informational.
///
///
///
public PORT_STATUS_TYPE dwSeverity;
}
/// Contains the execution context of the printer driver that calls GetPrintExecutionData.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/print-execution-data typedef struct _PRINT_EXECUTION_DATA {
// PRINT_EXECUTION_CONTEXT context; DWORD clientAppPID; } PRINT_EXECUTION_DATA;
[PInvokeData("winspool.h", MSDNShortId = "1fd25ed9-6f28-48f9-8132-d48fffc956ec")]
[StructLayout(LayoutKind.Sequential)]
public struct PRINT_EXECUTION_DATA
{
/// The PRINT_EXECUTION_CONTEXT value that represents the current execution context of the printer driver.
public PRINT_EXECUTION_CONTEXT context;
///
/// If the value of context is PRINT_EXECUTION_CONTEXT_WOW64, clientAppPID identifies the client
/// application on whose behalf the splwow64.exe process loaded the printer driver. If the value of context is not
/// PRINT_EXECUTION_CONTEXT_WOW64, clientAppPID is zero.
///
public uint clientAppPID;
}
/// Represents information about a connection to a printer.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-connection-info-1 typedef struct _PRINTER_CONNECTION_INFO_1 {
// DWORD dwFlags; LPTSTR pszDriverName; } PRINTER_CONNECTION_INFO_1, *PPRINTER_CONNECTION_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "afac3f91-74eb-46f7-94b4-d37b2b8a32a4")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_CONNECTION_INFO_1
{
///
/// The following values are defined:
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_CONNECTION_MISMATCH (0x00000020)
///
/// If this bit-flag is set, the printer connection is mismatched. The user can supply a local print driver as pszDriverName and
/// use it to do the rendering instead of using the driver installed on the server printer to which the user is connected.
///
///
/// -
/// PRINTER_CONNECTION_NO_UI (0x00000040)
///
/// If this bit-flag is set then this call cannot display a dialog box. If a dialog box must be displayed to install a printer
/// driver from the server and this bit-flag is set, the printer driver will not be installed, the printer connection will not
/// be added, and the call will fail. Windows 7: In Windows 7 and later versions of Windows, if this flag is set and the user is
/// running in elevated mode, the Do you trust this printer? dialog will not be shown.
///
///
///
///
public PRINTER_CONNECTION_FLAGS dwFlags;
/// A pointer to the name of the driver.
[MarshalAs(UnmanagedType.LPTStr)]
public string pszDriverName;
}
///
/// The PRINTER_ENUM_VALUES structure specifies the value name, type, and data for a printer configuration value returned by
/// the EnumPrinterDataEx function.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-enum-values typedef struct _PRINTER_ENUM_VALUES { LPTSTR
// pValueName; DWORD cbValueName; DWORD dwType; LPBYTE pData; DWORD cbData; } PRINTER_ENUM_VALUES, *PPRINTER_ENUM_VALUES;
[PInvokeData("winspool.h", MSDNShortId = "87eb1452-0d9d-46bd-8af8-0542a11a929b")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_ENUM_VALUES
{
/// Pointer to a null-terminated string that specifies the name of the retrieved value.
[MarshalAs(UnmanagedType.LPTStr)]
public string pValueName;
/// The number of bytes in the pValueName member, including the terminating NULL character.
public uint cbValueName;
///
/// A code indicating the type of data pointed to by the pData member. For a list of the possible type codes, see Registry Value Types.
///
public REG_VALUE_TYPE dwType;
/// Pointer to a buffer containing the data for the retrieved value.
public IntPtr pData;
/// The number of bytes retrieved in the pData buffer.
public uint cbData;
}
/// The PRINTER_INFO_1 structure specifies general printer information.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-1 typedef struct _PRINTER_INFO_1 { DWORD Flags; LPTSTR
// pDescription; LPTSTR pName; LPTSTR pComment; } PRINTER_INFO_1, *PPRINTER_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "0b0e2d0e-2625-4cab-a8f9-536185479443")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_INFO_1
{
///
/// Specifies information about the returned data. Following are the values for this member.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_ENUM_EXPAND
///
/// A print provider can set this flag as a hint to a calling application to enumerate this object further if default expansion
/// is enabled. For example, when domains are enumerated, a print provider might indicate the user's domain by setting this flag.
///
///
/// -
/// PRINTER_ENUM_CONTAINER
///
/// If this flag is set, the printer object may contain enumerable objects. For example, the object may be a print server that
/// contains printers.
///
///
/// -
/// PRINTER_ENUM_ICON1
///
/// Indicates that, where appropriate, an application should display an icon identifying the object as a top-level network name,
/// such as Microsoft Windows Network.
///
///
/// -
/// PRINTER_ENUM_ICON2
/// Indicates that, where appropriate, an application should display an icon that identifies the object as a network domain.
///
/// -
/// PRINTER_ENUM_ICON3
/// Indicates that, where appropriate, an application should display an icon that identifies the object as a print server.
///
/// -
/// PRINTER_ENUM_ICON4
/// Reserved.
///
/// -
/// PRINTER_ENUM_ICON5
/// Reserved.
///
/// -
/// PRINTER_ENUM_ICON6
/// Reserved.
///
/// -
/// PRINTER_ENUM_ICON7
/// Reserved.
///
/// -
/// PRINTER_ENUM_ICON8
/// Indicates that, where appropriate, an application should display an icon that identifies the object as a printer.
///
///
///
public PRINTER_ENUM Flags;
/// Pointer to a null-terminated string that describes the contents of the structure.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDescription;
/// Pointer to a null-terminated string that names the contents of the structure.
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
/// Pointer to a null-terminated string that contains additional data describing the structure.
[MarshalAs(UnmanagedType.LPTStr)]
public string pComment;
}
/// The PRINTER_INFO_2 structure specifies detailed printer information.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-2 typedef struct _PRINTER_INFO_2 { LPTSTR pServerName;
// LPTSTR pPrinterName; LPTSTR pShareName; LPTSTR pPortName; LPTSTR pDriverName; LPTSTR pComment; LPTSTR pLocation; LPDEVMODE
// pDevMode; LPTSTR pSepFile; LPTSTR pPrintProcessor; LPTSTR pDatatype; LPTSTR pParameters; PSECURITY_DESCRIPTOR
// pSecurityDescriptor; DWORD Attributes; DWORD Priority; DWORD DefaultPriority; DWORD StartTime; DWORD UntilTime; DWORD Status;
// DWORD cJobs; DWORD AveragePPM; } PRINTER_INFO_2, *PPRINTER_INFO_2;
[PInvokeData("winspool.h", MSDNShortId = "944cbfcd-9edf-4b60-a45c-9bb1839f8141")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_INFO_2
{
///
/// A pointer to a null-terminated string identifying the server that controls the printer. If this string is NULL, the
/// printer is controlled locally.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pServerName;
/// A pointer to a null-terminated string that specifies the name of the printer.
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrinterName;
///
/// A pointer to a null-terminated string that identifies the share point for the printer. (This string is used only if the
/// PRINTER_ATTRIBUTE_SHARED constant was set for the Attributes member.)
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pShareName;
///
/// A pointer to a null-terminated string that identifies the port(s) used to transmit data to the printer. If a printer is
/// connected to more than one port, the names of each port must be separated by commas (for example, "LPT1:,LPT2:,LPT3:").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pPortName;
/// A pointer to a null-terminated string that specifies the name of the printer driver.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDriverName;
/// A pointer to a null-terminated string that provides a brief description of the printer.
[MarshalAs(UnmanagedType.LPTStr)]
public string pComment;
///
/// A pointer to a null-terminated string that specifies the physical location of the printer (for example, "Bldg. 38, Room 1164").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pLocation;
///
/// A pointer to a DEVMODE structure that defines default printer data such as the paper orientation and the resolution.
///
public IntPtr pDevMode;
///
/// A pointer to a null-terminated string that specifies the name of the file used to create the separator page. This page is
/// used to separate print jobs sent to the printer.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pSepFile;
///
/// A pointer to a null-terminated string that specifies the name of the print processor used by the printer. You can use the
/// EnumPrintProcessors function to obtain a list of print processors installed on a server.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrintProcessor;
///
/// A pointer to a null-terminated string that specifies the data type used to record the print job. You can use the
/// EnumPrintProcessorDatatypes function to obtain a list of data types supported by a specific print processor.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pDatatype;
/// A pointer to a null-terminated string that specifies the default print-processor parameters.
[MarshalAs(UnmanagedType.LPTStr)]
public string pParameters;
/// A pointer to a SECURITY_DESCRIPTOR structure for the printer. This member may be NULL.
public PSECURITY_DESCRIPTOR pSecurityDescriptor;
///
/// The printer attributes. This member can be any reasonable combination of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_ATTRIBUTE_DIRECT
/// Job is sent directly to the printer (it is not spooled).
///
/// -
/// PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST
///
/// If set and printer is set for print-while-spooling, any jobs that have completed spooling are scheduled to print before jobs
/// that have not completed spooling.
///
///
/// -
/// PRINTER_ATTRIBUTE_ENABLE_DEVQ
///
/// If set, DevQueryPrint is called. DevQueryPrint may fail if the document and printer setups do not match. Setting this flag
/// causes mismatched documents to be held in the queue.
///
///
/// -
/// PRINTER_ATTRIBUTE_HIDDEN
/// Reserved.
///
/// -
/// PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS
/// If set, jobs are kept after they are printed. If unset, jobs are deleted.
///
/// -
/// PRINTER_ATTRIBUTE_LOCAL
/// Printer is a local printer.
///
/// -
/// PRINTER_ATTRIBUTE_NETWORK
/// Printer is a network printer connection.
///
/// -
/// PRINTER_ATTRIBUTE_PUBLISHED
/// Indicates whether the printer is published in the directory service.
///
/// -
/// PRINTER_ATTRIBUTE_QUEUED
///
/// If set, the printer spools and starts printing after the last page is spooled. If not set and PRINTER_ATTRIBUTE_DIRECT is
/// not set, the printer spools and prints while spooling.
///
///
/// -
/// PRINTER_ATTRIBUTE_RAW_ONLY
/// Indicates that only raw data type print jobs can be spooled.
///
/// -
/// PRINTER_ATTRIBUTE_SHARED
/// Printer is shared.
///
///
/// In Windows XP and later versions of Windows, the following value can also be used.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_ATTRIBUTE_FAX
///
/// If set, printer is a fax printer. This can only be set by AddPrinter, but it can be retrieved by EnumPrinters and GetPrinter.
///
///
///
/// In Windows Vista and later versions of Windows, the following values can also be used.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_ATTRIBUTE_FRIENDLY_NAME
/// A computer has connected to this printer and given it a friendly name.
///
/// -
/// PRINTER_ATTRIBUTE_MACHINE
/// Printer is a per-machine connection.
///
/// -
/// PRINTER_ATTRIBUTE_PUSHED_USER
/// The printer was installed by using the Push Printer Connections user policy.
///
/// -
/// PRINTER_ATTRIBUTE_PUSHED_MACHINE
/// The printer was installed by using the Push Printer Connections computer policy.
///
///
/// In Windows Server 2003, the following value can also be used.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_ATTRIBUTE_TS
/// Indicates the printer is currently connected through a terminal server.
///
///
///
public PRINTER_ATTRIBUTE Attributes;
/// A priority value that the spooler uses to route print jobs.
public uint Priority;
/// The default priority value assigned to each print job.
public uint DefaultPriority;
///
/// The earliest time at which the printer will print a job. This value is expressed as minutes elapsed since 12:00 AM GMT
/// (Greenwich Mean Time).
///
public uint StartTime;
///
/// The latest time at which the printer will print a job. This value is expressed as minutes elapsed since 12:00 AM GMT
/// (Greenwich Mean Time).
///
public uint UntilTime;
///
/// The printer status. This member can be any reasonable combination of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_STATUS_BUSY
/// The printer is busy.
///
/// -
/// PRINTER_STATUS_DOOR_OPEN
/// The printer door is open.
///
/// -
/// PRINTER_STATUS_ERROR
/// The printer is in an error state.
///
/// -
/// PRINTER_STATUS_INITIALIZING
/// The printer is initializing.
///
/// -
/// PRINTER_STATUS_IO_ACTIVE
/// The printer is in an active input/output state
///
/// -
/// PRINTER_STATUS_MANUAL_FEED
/// The printer is in a manual feed state.
///
/// -
/// PRINTER_STATUS_NO_TONER
/// The printer is out of toner.
///
/// -
/// PRINTER_STATUS_NOT_AVAILABLE
/// The printer is not available for printing.
///
/// -
/// PRINTER_STATUS_OFFLINE
/// The printer is offline.
///
/// -
/// PRINTER_STATUS_OUT_OF_MEMORY
/// The printer has run out of memory.
///
/// -
/// PRINTER_STATUS_OUTPUT_BIN_FULL
/// The printer's output bin is full.
///
/// -
/// PRINTER_STATUS_PAGE_PUNT
/// The printer cannot print the current page.
///
/// -
/// PRINTER_STATUS_PAPER_JAM
/// Paper is jammed in the printer
///
/// -
/// PRINTER_STATUS_PAPER_OUT
/// The printer is out of paper.
///
/// -
/// PRINTER_STATUS_PAPER_PROBLEM
/// The printer has a paper problem.
///
/// -
/// PRINTER_STATUS_PAUSED
/// The printer is paused.
///
/// -
/// PRINTER_STATUS_PENDING_DELETION
/// The printer is being deleted.
///
/// -
/// PRINTER_STATUS_POWER_SAVE
/// The printer is in power save mode.
///
/// -
/// PRINTER_STATUS_PRINTING
/// The printer is printing.
///
/// -
/// PRINTER_STATUS_PROCESSING
/// The printer is processing a print job.
///
/// -
/// PRINTER_STATUS_SERVER_UNKNOWN
/// The printer status is unknown.
///
/// -
/// PRINTER_STATUS_TONER_LOW
/// The printer is low on toner.
///
/// -
/// PRINTER_STATUS_USER_INTERVENTION
/// The printer has an error that requires the user to do something.
///
/// -
/// PRINTER_STATUS_WAITING
/// The printer is waiting.
///
/// -
/// PRINTER_STATUS_WARMING_UP
/// The printer is warming up.
///
///
///
public PRINTER_STATUS Status;
/// The number of print jobs that have been queued for the printer.
public uint cJobs;
/// The average number of pages per minute that have been printed on the printer.
public uint AveragePPM;
/// A DEVMODE structure that contains device-initialization and environment data for the printer driver.
public DEVMODE DevMode => pDevMode.ToStructure();
}
/// The PRINTER_INFO_3 structure specifies printer security information.
///
/// The PRINTER_INFO_3 structure lets an application get and set a printer's security descriptor. The caller may do so even
/// if it lacks specific printer permissions, as long as it has the standard rights described in SetPrinter and
/// GetPrinter. Thus, an application may temporarily deny all access to a printer, while allowing the owner of the printer to
/// have access to the printer's discretionary ACL.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-3 typedef struct _PRINTER_INFO_3 { PSECURITY_DESCRIPTOR
// pSecurityDescriptor; } PRINTER_INFO_3, *PPRINTER_INFO_3;
[PInvokeData("winspool.h", MSDNShortId = "527d635d-2d75-4b56-bab7-e95c9919a8fb")]
[StructLayout(LayoutKind.Sequential)]
public struct PRINTER_INFO_3
{
/// Pointer to a SECURITY_DESCRIPTOR structure that specifies a printer's security information.
public PSECURITY_DESCRIPTOR pSecurityDescriptor;
}
///
/// The PRINTER_INFO_4 structure specifies general printer information.
///
/// The structure can be used to retrieve minimal printer information on a call to EnumPrinters. Such a call is a fast and
/// easy way to retrieve the names and attributes of all locally installed printers on a system and all remote printer connections
/// that a user has established.
///
///
///
///
/// The PRINTER_INFO_4 structure provides an easy and extremely fast way to retrieve the names of the printers installed on a
/// local machine, as well as the remote connections that a user has established. When EnumPrinters is called with a
/// PRINTER_INFO_4 data structure, that function queries the registry for the specified information, then returns
/// immediately. This differs from the behavior of EnumPrinters when called with other levels of PRINTER_INFO_xxx data
/// structures. In particular, when EnumPrinters is called with a level 2 ( PRINTER_INFO_2 ) data structure, it
/// performs an OpenPrinter call on each remote connection. If a remote connection is down, if the remote server no longer
/// exists, or if the remote printer no longer exists, the function must wait for RPC to time out and consequently fail the
/// OpenPrinter call. This can take a while. Passing a PRINTER_INFO_4 structure lets an application retrieve a bare
/// minimum of required information; if more detailed information is desired, a subsequent EnumPrinter level 2 call can be made.
///
/// Attributes can also contain values that are defined in the Attributes field of PRINTER_INFO_2.
///
/// Some printer configurations, such as printer connections to some non-Windows-based print servers, might return both
/// PRINTER_ATTRIBUTE_LOCAL and PRINTER_ATTRIBUTE_NETWORK.
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-4 typedef struct _PRINTER_INFO_4 { LPTSTR pPrinterName;
// LPTSTR pServerName; DWORD Attributes; } PRINTER_INFO_4, *PPRINTER_INFO_4;
[PInvokeData("winspool.h", MSDNShortId = "81bd0eab-dc1e-4cf1-8f63-3686f1711c1f")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_INFO_4
{
/// Pointer to a null-terminated string that specifies the name of the printer (local or remote).
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrinterName;
/// Pointer to a null-terminated string that is the name of the server.
[MarshalAs(UnmanagedType.LPTStr)]
public string pServerName;
///
/// Specifies information about the returned data.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_ATTRIBUTE_LOCAL
/// The printer is a local printer.
///
/// -
/// PRINTER_ATTRIBUTE_NETWORK
/// The printer is a remote printer.
///
///
///
public PRINTER_ATTRIBUTE Attributes;
}
/// The PRINTER_INFO_5 structure specifies detailed printer information.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-5 typedef struct _PRINTER_INFO_5 { LPTSTR pPrinterName;
// LPTSTR pPortName; DWORD Attributes; DWORD DeviceNotSelectedTimeout; DWORD TransmissionRetryTimeout; } PRINTER_INFO_5, *PPRINTER_INFO_5;
[PInvokeData("winspool.h", MSDNShortId = "c8599f2e-3b7c-4fde-a340-ca7d3ddaa106")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_INFO_5
{
/// A pointer to a null-terminated string that specifies the name of the printer.
[MarshalAs(UnmanagedType.LPTStr)]
public string pPrinterName;
///
/// A pointer to a null-terminated string that identifies the port(s) used to transmit data to the printer. If a printer is
/// connected to more than one port, the names of each port must be separated by commas (for example, "LPT1:,LPT2:,LPT3:").
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pPortName;
///
/// The printer attributes. This member can be any reasonable combination of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_ATTRIBUTE_DIRECT
/// Job is sent directly to the printer (it is not spooled).
///
/// -
/// PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST
///
/// If set and printer is set for print-while-spooling, any jobs that have completed spooling are scheduled to print before jobs
/// that have not completed spooling.
///
///
/// -
/// PRINTER_ATTRIBUTE_ENABLE_DEVQ
///
/// If set, DevQueryPrint is called. DevQueryPrint may fail if the document and printer setups do not match. Setting this flag
/// causes mismatched documents to be held in the queue.
///
///
/// -
/// PRINTER_ATTRIBUTE_HIDDEN
/// Reserved.
///
/// -
/// PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS
/// If set, jobs are kept after they are printed. If unset, jobs are deleted.
///
/// -
/// PRINTER_ATTRIBUTE_LOCAL
/// Printer is a local printer.
///
/// -
/// PRINTER_ATTRIBUTE_NETWORK
/// Printer is a network printer connection.
///
/// -
/// PRINTER_ATTRIBUTE_PUBLISHED
/// Indicates whether the printer is published in the directory service.
///
/// -
/// PRINTER_ATTRIBUTE_QUEUED
///
/// If set, the printer spools and starts printing after the last page is spooled. If not set and PRINTER_ATTRIBUTE_DIRECT is
/// not set, the printer spools and prints while spooling.
///
///
/// -
/// PRINTER_ATTRIBUTE_RAW_ONLY
/// Indicates that only raw data type print jobs can be spooled.
///
/// -
/// PRINTER_ATTRIBUTE_SHARED
/// Printer is shared.
///
///
/// In Windows XP and later versions of Windows, the following value can also be used.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_ATTRIBUTE_FAX
///
/// If set, printer is a fax printer. This can only be set by AddPrinter, but it can be retrieved by EnumPrinters and GetPrinter.
///
///
///
/// In Windows Vista and later versions of Windows, the following values can also be used.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_ATTRIBUTE_FRIENDLY_NAME
/// A computer has connected to this printer and given it a friendly name.
///
/// -
/// PRINTER_ATTRIBUTE_MACHINE
/// Printer is a per-machine connection.
///
/// -
/// PRINTER_ATTRIBUTE_PUSHED_USER
/// The printer was installed by using the Push Printer Connections user policy.
///
/// -
/// PRINTER_ATTRIBUTE_PUSHED_MACHINE
/// The printer was installed by using the Push Printer Connections computer policy.
///
///
///
public PRINTER_ATTRIBUTE Attributes;
/// This value is not used.
public uint DeviceNotSelectedTimeout;
/// This value is not used.
public uint TransmissionRetryTimeout;
}
/// The PRINTER_INFO_6 specifies the status value of a printer.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-6 typedef struct _PRINTER_INFO_6 { DWORD dwStatus; }
// PRINTER_INFO_6, *PPRINTER_INFO_6;
[PInvokeData("winspool.h", MSDNShortId = "f26fe75b-7c97-47ad-892f-d9e40331fa5d")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_INFO_6
{
///
/// The printer status. This member can be any reasonable combination of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// PRINTER_STATUS_BUSY
/// The printer is busy.
///
/// -
/// PRINTER_STATUS_DOOR_OPEN
/// The printer door is open.
///
/// -
/// PRINTER_STATUS_ERROR
/// Not used.
///
/// -
/// PRINTER_STATUS_INITIALIZING
/// The printer is initializing.
///
/// -
/// PRINTER_STATUS_IO_ACTIVE
/// The printer is in an active input/output state
///
/// -
/// PRINTER_STATUS_MANUAL_FEED
/// The printer is in a manual feed state.
///
/// -
/// PRINTER_STATUS_NO_TONER
/// The printer is out of toner.
///
/// -
/// PRINTER_STATUS_NOT_AVAILABLE
/// The printer is not available for printing.
///
/// -
/// PRINTER_STATUS_OFFLINE
/// The printer is offline.
///
/// -
/// PRINTER_STATUS_OUT_OF_MEMORY
/// The printer has run out of memory.
///
/// -
/// PRINTER_STATUS_OUTPUT_BIN_FULL
/// The printer's output bin is full.
///
/// -
/// PRINTER_STATUS_PAGE_PUNT
/// The printer cannot print the current page.
///
/// -
/// PRINTER_STATUS_PAPER_JAM
/// Paper is jammed in the printer
///
/// -
/// PRINTER_STATUS_PAPER_OUT
/// The printer is out of paper.
///
/// -
/// PRINTER_STATUS_PAPER_PROBLEM
/// The printer has a paper problem.
///
/// -
/// PRINTER_STATUS_PAUSED
/// The printer is paused.
///
/// -
/// PRINTER_STATUS_PENDING_DELETION
/// The printer is pending deletion as a result of a call to the DeletePrinter function.
///
/// -
/// PRINTER_STATUS_POWER_SAVE
/// The printer is in power save mode.
///
/// -
/// PRINTER_STATUS_PRINTING
/// The printer is printing.
///
/// -
/// PRINTER_STATUS_PROCESSING
/// The printer is processing a command from the SetPrinter function.
///
/// -
/// PRINTER_STATUS_SERVER_UNKNOWN
/// The printer status is unknown.
///
/// -
/// PRINTER_STATUS_TONER_LOW
/// The printer is low on toner.
///
/// -
/// PRINTER_STATUS_USER_INTERVENTION
/// The printer has an error that requires the user to do something.
///
/// -
/// PRINTER_STATUS_WAITING
/// The printer is waiting.
///
/// -
/// PRINTER_STATUS_WARMING_UP
/// The printer is warming up.
///
///
///
public PRINTER_STATUS dwStatus;
}
///
/// The PRINTER_INFO_7 structure specifies directory services printer information. Use this structure with the
/// SetPrinter function to publish a printer's data in the directory service (DS), or to update or remove a printer's
/// published data from the DS. Use this structure with the GetPrinter function to determine whether a printer is published
/// in the DS.
///
///
///
/// The PRINTER_INFO_7 structure is used in a SetPrinter call to publish printer information to the directory service.
/// The published data includes all values and data for the specified printer found under the SPLDS_SPOOLER_KEY, SPLDS_DRIVER_KEY,
/// or SPLDS_USER_KEY keys created by SetPrinterDataEx.
///
///
/// For SetPrinter, pszObjectGUID should be set to NULL. For GetPrinter, pszObjectGUID returns the GUID of the
/// directory services print queue object associated with a published printer. You can use this GUID with Active Directory Services
/// Interface (ADSI) methods to retrieve published data for the printer. However, the recommended method for retrieving published
/// data is to call the GetPrinterDataEx function.
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-7 typedef struct _PRINTER_INFO_7 { LPTSTR pszObjectGUID;
// DWORD dwAction; } PRINTER_INFO_7, *PPRINTER_INFO_7;
[PInvokeData("winspool.h", MSDNShortId = "9443855e-df7d-41a1-a0df-5649a97b2915")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_INFO_7
{
///
///
/// A pointer to a null-terminated string containing the GUID of the directory service print queue object associated with a
/// published printer. Use the GetPrinter function to retrieve this GUID.
///
/// Before calling SetPrinter, set pszObjectGUID to NULL.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pszObjectGUID;
///
///
/// Indicates the action for the SetPrinter function to perform. For the GetPrinter function, this member
/// indicates whether the specified printer is published. This member can be a combination of the following values.
///
///
///
/// Value
/// Meaning
///
/// -
/// DSPRINT_PENDING 0x80000000
///
/// GetPrinter: Indicates that the system is attempting to complete a publish or unpublish operation started by a SetPrinter
/// call. SetPrinter: This value is not valid.
///
///
/// -
/// DSPRINT_PUBLISH 0x00000001
/// SetPrinter: Publishes the printer's data in the DS. GetPrinter: Indicates the printer is published.
///
/// -
/// DSPRINT_REPUBLISH 0x00000008
///
/// SetPrinter: The DS data for the printer is unpublished and then published again, refreshing all properties in the published
/// printer. Re-publishing also changes the GUID of the published printer. GetPrinter: Never returns this value.
///
///
/// -
/// DSPRINT_UNPUBLISH 0x00000004
/// SetPrinter: Removes the printer's published data from the DS. GetPrinter: Indicates the printer is not published.
///
/// -
/// DSPRINT_UPDATE 0x00000002
/// SetPrinter: Updates the printer's published data in the DS. GetPrinter: Never returns this value.
///
///
///
public DSPRINT dwAction;
}
/// The PRINTER_INFO_8 structure specifies the global default printer settings.
///
/// The global defaults are set by the administrator of a printer that can be used by anyone. In contrast, the per-user defaults
/// will affect a particular user or anyone else who uses the profile. For per-user defaults, use PRINTER_INFO_9.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-8 typedef struct _PRINTER_INFO_8 { LPDEVMODE pDevMode; }
// PRINTER_INFO_8, *PPRINTER_INFO_8;
[PInvokeData("winspool.h", MSDNShortId = "98f26a45-5302-4358-bed6-691d9bc37554")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_INFO_8
{
///
/// A pointer to a DEVMODE structure that defines the global default printer data such as the paper orientation and the resolution.
///
public IntPtr pDevMode;
/// A DEVMODE structure that contains device-initialization and environment data for the printer driver.
public DEVMODE DevMode => pDevMode.ToStructure();
}
/// The PRINTER_INFO_9 structure specifies the per-user default printer settings.
///
/// The per-user defaults will affect only a particular user or anyone who uses the profile. In contrast, the global defaults are
/// set by the administrator of a printer that can be used by anyone. For global defaults, use PRINTER_INFO_8.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-info-9 typedef struct _PRINTER_INFO_9 { LPDEVMODE pDevMode; }
// PRINTER_INFO_9, *PPRINTER_INFO_9;
[PInvokeData("winspool.h", MSDNShortId = "8bafb995-f31c-46e3-a950-45e240c678aa")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_INFO_9
{
///
/// A pointer to a DEVMODE structure that defines the per-user default printer data such as the paper orientation and the
/// resolution. The DEVMODE is stored in the user's registry.
///
public IntPtr pDevMode;
/// A DEVMODE structure that contains device-initialization and environment data for the printer driver.
public DEVMODE DevMode => pDevMode.ToStructure();
}
///
/// The PRINTER_NOTIFY_INFO structure contains printer information returned by the FindNextPrinterChangeNotification
/// function. The function returns this information after a wait operation on a printer change notification object has been satisfied.
///
///
/// If the Flags member has the PRINTER_NOTIFY_INFO_DISCARDED bit set, this indicates that an overflow or error occurred, and
/// notifications may have been lost. In this case, you must call FindNextPrinterChangeNotification and specify the
/// PRINTER_NOTIFY_OPTIONS_REFRESH flag to retrieve all current information. Until you request this refresh operation, the system
/// will not send additional notifications for this change notification object.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-notify-info typedef struct _PRINTER_NOTIFY_INFO { DWORD Version;
// DWORD Flags; DWORD Count; PRINTER_NOTIFY_INFO_DATA aData[1]; } PRINTER_NOTIFY_INFO, *PPRINTER_NOTIFY_INFO;
[PInvokeData("winspool.h", MSDNShortId = "c104fabe-edf5-426e-859b-694811975623")]
[StructLayout(LayoutKind.Sequential)]
[VanaraMarshaler(typeof(SafeAnysizeStructMarshaler), nameof(Count))]
public struct PRINTER_NOTIFY_INFO
{
/// The version of this structure. Set this member to 2.
public uint Version;
///
/// A bit flag that indicates the state of the notification structure. If the PRINTER_NOTIFY_INFO_DISCARDED bit is set, it
/// indicates that some notifications had to be discarded.
///
public uint Flags;
/// The number of PRINTER_NOTIFY_INFO_DATA elements in the aData array.
public uint Count;
///
/// An array of PRINTER_NOTIFY_INFO_DATA structures. Each element of the array identifies a single job or printer
/// information field, and provides the current data for that field.
///
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public PRINTER_NOTIFY_INFO_DATA[] aData;
}
///
///
/// The PRINTER_NOTIFY_INFO_DATA structure identifies a job or printer information field and provides the current data for
/// that field.
///
///
/// The FindNextPrinterChangeNotification function returns a PRINTER_NOTIFY_INFO structure, which contains an array of
/// PRINTER_NOTIFY_INFO_DATA structures.
///
///
///
/// If the Type member specifies PRINTER_NOTIFY_TYPE, the Field member can be one of the following values.
///
///
/// Field
/// Type of data
/// Value
///
/// -
/// PRINTER_NOTIFY_FIELD_SERVER_NAME
/// Not supported.
/// 0x00
///
/// -
/// PRINTER_NOTIFY_FIELD_PRINTER_NAME
/// pBuf is a pointer to a null-terminated string containing the name of the printer.
/// 0x01
///
/// -
/// PRINTER_NOTIFY_FIELD_SHARE_NAME
/// pBuf is a pointer to a null-terminated string that identifies the share point for the printer.
/// 0x02
///
/// -
/// PRINTER_NOTIFY_FIELD_PORT_NAME
///
/// pBuf is a pointer to a null-terminated string containing the name of the port that the print jobs will be printed to. If
/// "Printer Pooling" is selected, this is a comma separated list of ports.
///
/// 0x03
///
/// -
/// PRINTER_NOTIFY_FIELD_DRIVER_NAME
/// pBuf is a pointer to a null-terminated string containing the name of the printer's driver.
/// 0x04
///
/// -
/// PRINTER_NOTIFY_FIELD_COMMENT
///
/// pBuf is a pointer to a null-terminated string containing the new comment string, which is typically a brief description of the printer.
///
/// 0x05
///
/// -
/// PRINTER_NOTIFY_FIELD_LOCATION
///
/// pBuf is a pointer to a null-terminated string containing the new physical location of the printer (for example, "Bldg. 38, Room 1164").
///
/// 0x06
///
/// -
/// PRINTER_NOTIFY_FIELD_DEVMODE
/// pBuf is a pointer to a DEVMODE structure that defines default printer data such as the paper orientation and the resolution.
/// 0x07
///
/// -
/// PRINTER_NOTIFY_FIELD_SEPFILE
///
/// pBuf is a pointer to a null-terminated string that specifies the name of the file used to create the separator page. This page
/// is used to separate print jobs sent to the printer.
///
/// 0x08
///
/// -
/// PRINTER_NOTIFY_FIELD_PRINT_PROCESSOR
/// pBuf is a pointer to a null-terminated string that specifies the name of the print processor used by the printer.
/// 0x09
///
/// -
/// PRINTER_NOTIFY_FIELD_PARAMETERS
/// pBuf is a pointer to a null-terminated string that specifies the default print-processor parameters.
/// 0x0A
///
/// -
/// PRINTER_NOTIFY_FIELD_DATATYPE
/// pBuf is a pointer to a null-terminated string that specifies the data type used to record the print job.
/// 0x0B
///
/// -
/// PRINTER_NOTIFY_FIELD_SECURITY_DESCRIPTOR
///
/// pBuf is a pointer to a SECURITY_DESCRIPTOR structure for the printer. The pointer may be NULL if there is no security descriptor.
///
/// 0x0C
///
/// -
/// PRINTER_NOTIFY_FIELD_ATTRIBUTES
///
/// adwData [0] specifies the printer attributes, which can be one of the following values: PRINTER_ATTRIBUTE_QUEUED
/// PRINTER_ATTRIBUTE_DIRECT PRINTER_ATTRIBUTE_DEFAULT PRINTER_ATTRIBUTE_SHARED
///
/// 0x0D
///
/// -
/// PRINTER_NOTIFY_FIELD_PRIORITY
/// adwData [0] specifies a priority value that the spooler uses to route print jobs.
/// 0x0E
///
/// -
/// PRINTER_NOTIFY_FIELD_DEFAULT_PRIORITY
/// adwData [0] specifies the default priority value assigned to each print job.
/// 0x0F
///
/// -
/// PRINTER_NOTIFY_FIELD_START_TIME
///
/// adwData [0] specifies the earliest time at which the printer will print a job. (This value is specified in minutes elapsed since
/// 12:00 A.M.)
///
/// 0x10
///
/// -
/// PRINTER_NOTIFY_FIELD_UNTIL_TIME
///
/// adwData [0] specifies the latest time at which the printer will print a job. (This value is specified in minutes elapsed since
/// 12:00 A.M.)
///
/// 0x11
///
/// -
/// PRINTER_NOTIFY_FIELD_STATUS
/// adwData [0] specifies the printer status. For a list of possible values, see the PRINTER_INFO_2 structure.
/// 0x12
///
/// -
/// PRINTER_NOTIFY_FIELD_STATUS_STRING
/// Not supported.
/// 0x13
///
/// -
/// PRINTER_NOTIFY_FIELD_CJOBS
/// adwData [0] specifies the number of print jobs that have been queued for the printer.
/// 0x14
///
/// -
/// PRINTER_NOTIFY_FIELD_AVERAGE_PPM
/// adwData [0] specifies the average number of pages per minute that have been printed on the printer.
/// 0x15
///
/// -
/// PRINTER_NOTIFY_FIELD_TOTAL_PAGES
/// Not supported.
/// 0x16
///
/// -
/// PRINTER_NOTIFY_FIELD_PAGES_PRINTED
/// Not supported.
/// 0x17
///
/// -
/// PRINTER_NOTIFY_FIELD_TOTAL_BYTES
/// Not supported.
/// 0x18
///
/// -
/// PRINTER_NOTIFY_FIELD_BYTES_PRINTED
/// Not supported.
/// 0x19
///
/// -
/// PRINTER_NOTIFY_FIELD_OBJECT_GUID
/// This is set if the object GUID changes.
/// 0x1A
///
/// -
/// PRINTER_NOTIFY_FIELD_FRIENDLY_NAME
/// This is set if the printer connection is renamed.
/// 0x1B
///
///
/// If the Type member specifies JOB_NOTIFY_TYPE, the Field member can be one of the following values.
///
///
/// Field
/// Type of data
/// Value
///
/// -
/// JOB_NOTIFY_FIELD_PRINTER_NAME
/// pBuf is a pointer to a null-terminated string containing the name of the printer for which the job is spooled.
/// 0x00
///
/// -
/// JOB_NOTIFY_FIELD_MACHINE_NAME
/// pBuf is a pointer to a null-terminated string that specifies the name of the machine that created the print job.
/// 0x01
///
/// -
/// JOB_NOTIFY_FIELD_PORT_NAME
///
/// pBuf is a pointer to a null-terminated string that identifies the port(s) used to transmit data to the printer. If a printer is
/// connected to more than one port, the names of the ports are separated by commas (for example, "LPT1:,LPT2:,LPT3:").
///
/// 0x02
///
/// -
/// JOB_NOTIFY_FIELD_USER_NAME
/// pBuf is a pointer to a null-terminated string that specifies the name of the user who sent the print job.
/// 0x03
///
/// -
/// JOB_NOTIFY_FIELD_NOTIFY_NAME
///
/// pBuf is a pointer to a null-terminated string that specifies the name of the user who should be notified when the job has been
/// printed or when an error occurs while printing the job.
///
/// 0x04
///
/// -
/// JOB_NOTIFY_FIELD_DATATYPE
/// pBuf is a pointer to a null-terminated string that specifies the type of data used to record the print job.
/// 0x05
///
/// -
/// JOB_NOTIFY_FIELD_PRINT_PROCESSOR
/// pBuf is a pointer to a null-terminated string that specifies the name of the print processor to be used to print the job.
/// 0x06
///
/// -
/// JOB_NOTIFY_FIELD_PARAMETERS
/// pBuf is a pointer to a null-terminated string that specifies print-processor parameters.
/// 0x07
///
/// -
/// JOB_NOTIFY_FIELD_DRIVER_NAME
///
/// pBuf is a pointer to a null-terminated string that specifies the name of the printer driver that should be used to process the
/// print job.
///
/// 0x08
///
/// -
/// JOB_NOTIFY_FIELD_DEVMODE
/// pBuf is a pointer to a DEVMODE structure that contains device-initialization and environment data for the printer driver.
/// 0x09
///
/// -
/// JOB_NOTIFY_FIELD_STATUS
/// adwData [0] specifies the job status. For a list of possible values, see the JOB_INFO_2 structure.
/// 0x0A
///
/// -
/// JOB_NOTIFY_FIELD_STATUS_STRING
/// pBuf is a pointer to a null-terminated string that specifies the status of the print job.
/// 0x0B
///
/// -
/// JOB_NOTIFY_FIELD_SECURITY_DESCRIPTOR
/// Not supported.
/// 0x0C
///
/// -
/// JOB_NOTIFY_FIELD_DOCUMENT
/// pBuf is a pointer to a null-terminated string that specifies the name of the print job (for example, "MS-WORD: Review.doc").
/// 0x0D
///
/// -
/// JOB_NOTIFY_FIELD_PRIORITY
/// adwData [0] specifies the job priority.
/// 0x0E
///
/// -
/// JOB_NOTIFY_FIELD_POSITION
/// adwData [0] specifies the job's position in the print queue.
/// 0x0F
///
/// -
/// JOB_NOTIFY_FIELD_SUBMITTED
/// pBuf is a pointer to a SYSTEMTIME structure that specifies the time when the job was submitted.
/// 0x10
///
/// -
/// JOB_NOTIFY_FIELD_START_TIME
///
/// adwData [0] specifies the earliest time that the job can be printed. (This value is specified in minutes elapsed since 12:00 A.M.)
///
/// 0x11
///
/// -
/// JOB_NOTIFY_FIELD_UNTIL_TIME
///
/// adwData [0] specifies the latest time that the job can be printed. (This value is specified in minutes elapsed since 12:00 A.M.)
///
/// 0x12
///
/// -
/// JOB_NOTIFY_FIELD_TIME
/// adwData [0] specifies the total time, in seconds, that has elapsed since the job began printing.
/// 0x13
///
/// -
/// JOB_NOTIFY_FIELD_TOTAL_PAGES
/// adwData [0] specifies the size, in pages, of the job.
/// 0x14
///
/// -
/// JOB_NOTIFY_FIELD_PAGES_PRINTED
/// adwData [0] specifies the number of pages that have printed.
/// 0x15
///
/// -
/// JOB_NOTIFY_FIELD_TOTAL_BYTES
/// adwData [0] specifies the size, in bytes, of the job.
/// 0x16
///
/// -
/// JOB_NOTIFY_FIELD_BYTES_PRINTED
///
/// adwData [0] specifies the number of bytes that have been printed on this job. For this field, the change notification object is
/// signaled when bytes are sent to the printer.
///
/// 0x17
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-notify-info-data typedef struct _PRINTER_NOTIFY_INFO_DATA { WORD
// Type; WORD Field; DWORD Reserved; DWORD Id; union { DWORD adwData[2]; struct { DWORD cbBuf; LPVOID pBuf; } Data; } NotifyData; }
// PRINTER_NOTIFY_INFO_DATA, *PPRINTER_NOTIFY_INFO_DATA; ;
[PInvokeData("winspool.h", MSDNShortId = "7a7b9e01-32e0-47f8-a5b1-5f7e6a663714")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTER_NOTIFY_INFO_DATA
{
///
/// Indicates the type of information provided. This member can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// JOB_NOTIFY_TYPE 0x01
/// Indicates that the Field member specifies a JOB_NOTIFY_FIELD_* constant.
///
/// -
/// PRINTER_NOTIFY_TYPE 0x00
/// Indicates that the Field member specifies a PRINTER_NOTIFY_FIELD_* constant.
///
///
///
public NOTIFY_TYPE Type;
/// Indicates the field that changed. For a list of possible values, see the Remarks section.
public ushort Field;
/// Reserved.
public uint Reserved;
///
/// Indicates the job identifier if the Type member specifies JOB_NOTIFY_TYPE. If the Type member specifies
/// PRINTER_NOTIFY_TYPE, this member is undefined.
///
public uint Id;
///
/// A union of data information based on the Type and Field members. For a description of the type of data
/// associated with each field, see the Remarks section.
///
public NOTIFYDATA NotifyData;
///
/// A union of data information based on the Type and Field members. For a description of the type of data
/// associated with each field, see the Remarks section.
///
[StructLayout(LayoutKind.Explicit)]
public struct NOTIFYDATA
{
///
/// The first item in an array of two DWORD values. For information fields that use only a single DWORD, the data is in this field.
///
[FieldOffset(0)]
public uint adwData0;
/// The second item in an array of two DWORD values.
[FieldOffset(4)]
public uint adwData1;
/// Contains variable length data.
[FieldOffset(0)]
public DATA Data;
/// Contains variable length data.
[StructLayout(LayoutKind.Sequential)]
public struct DATA
{
/// Indicates the size, in bytes, of the buffer pointed to by pBuf.
public uint cbBuf;
/// Pointer to a buffer that contains the field's current data.
public IntPtr pBuf;
}
}
}
///
/// The PRINTER_NOTIFY_OPTIONS structure specifies options for a change notification object that monitors a printer or print server.
///
///
///
/// Use this structure with the FindFirstPrinterChangeNotification function to specify the set of printer or job information
/// fields to monitor for change.
///
///
/// Use this structure with the FindNextPrinterChangeNotification function to request the current data for all monitored
/// printer and job information fields. In this case, the Flags member specifies the PRINTER_NOTIFY_OPTIONS_REFRESH flag, and
/// the function ignores the other structure members.
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-notify-options typedef struct _PRINTER_NOTIFY_OPTIONS { DWORD
// Version; DWORD Flags; DWORD Count; PPRINTER_NOTIFY_OPTIONS_TYPE pTypes; } PRINTER_NOTIFY_OPTIONS, *PPRINTER_NOTIFY_OPTIONS;
[PInvokeData("", MSDNShortId = "712c546d-dbb3-4f78-b14e-fbb8619b57f9")]
[StructLayout(LayoutKind.Sequential)]
public struct PRINTER_NOTIFY_OPTIONS
{
/// The version of this structure. Set this member to 2.
public uint Version;
///
/// A bit flag. If you set the PRINTER_NOTIFY_OPTIONS_REFRESH flag in a call to the FindNextPrinterChangeNotification
/// function, the function provides current data for all monitored printer information fields. The
/// FindFirstPrinterChangeNotification function ignores the Flags member.
///
public PRINTER_NOTIFY_OPTIONS_FLAG Flags;
/// The number of elements in the pTypes array.
public uint Count;
///
/// A pointer to an array of PRINTER_NOTIFY_OPTIONS_TYPE structures. Use one element of this array to specify the printer
/// information fields to monitor, and one element to specify the job information fields to monitor. You can monitor either
/// printer information, job information, or both.
///
public IntPtr pTypes;
}
///
///
/// The PRINTER_NOTIFY_OPTIONS_TYPE structure specifies the set of printer or job information fields to be monitored by a
/// printer change notification object.
///
///
/// A call to the FindFirstPrinterChangeNotification function specifies a PRINTER_NOTIFY_OPTIONS structure, which
/// contains an array of PRINTER_NOTIFY_OPTIONS_TYPE structures.
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-notify-options-type typedef struct _PRINTER_NOTIFY_OPTIONS_TYPE
// { WORD Type; WORD Reserved0; DWORD Reserved1; DWORD Reserved2; DWORD Count; PWORD pFields; } PRINTER_NOTIFY_OPTIONS_TYPE, *PPRINTER_NOTIFY_OPTIONS_TYPE;
[PInvokeData("winspool.h", MSDNShortId = "1009f892-d3a8-4887-99b4-a35d1268eeb4")]
[StructLayout(LayoutKind.Sequential)]
public struct PRINTER_NOTIFY_OPTIONS_TYPE
{
///
/// The type to be watched. This member can be one of the following values.
///
///
/// Value
/// Meaning
///
/// -
/// JOB_NOTIFY_TYPE 0x01
/// Indicates that the fields specified in the pFields array are JOB_NOTIFY_FIELD_* constants.
///
/// -
/// PRINTER_NOTIFY_TYPE 0x00
/// Indicates that the fields specified in the pFields array are PRINTER_NOTIFY_FIELD_* constants.
///
///
///
public NOTIFY_TYPE Type;
/// Reserved.
public ushort Reserved0;
/// Reserved.
public uint Reserved1;
/// Reserved.
public uint Reserved2;
/// The number of elements in the pFields array.
public uint Count;
///
/// A pointer to an array of values. Each element of the array specifies a job or printer information field of interest. For a
/// list of supported printer and job information fields, see the PRINTER_NOTIFY_INFO_DATA structure.
///
public IntPtr pFields;
}
/// Represents printer options.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printer-options typedef struct _PRINTER_OPTIONS { UINT cbSize; DWORD
// dwFlags; } PRINTER_OPTIONS, *PPRINTER_OPTIONS;
[PInvokeData("winspool.h", MSDNShortId = "7cc3d10c-8bc2-4899-b083-63d802ee16e7")]
[StructLayout(LayoutKind.Sequential)]
public struct PRINTER_OPTIONS
{
/// The size of the PRINTER_OPTIONS structure.
public uint cbSize;
///
/// A set of PRINTER_OPTION_FLAGS that specifies how the handle to a printer returned by OpenPrinter2 will be used
/// by other functions.
///
public PRINTER_OPTION_FLAGS dwFlags;
/// An instance with the size preset.
public static readonly PRINTER_OPTIONS Default = new PRINTER_OPTIONS { cbSize = 8 };
}
///
/// The PRINTPROCESSOR_CAPS_1 structure is the format for the printer capability information that is returned by the
/// GetPrinterData function in the buffer specified by the pData variable.
///
///
///
/// Values for all structure members are supplied by the GetPrintProcessorCapabilities function, which is documented in the
/// Windows Driver Kit (WDK).
///
///
/// The spooler calls a print processor's GetPrintProcessorCapabilities function when an application calls
/// GetPrinterData, specifying a value name with a format of PrintProcCaps_datatype, where datatype is the name of an input
/// data type.
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printprocessor-caps-1 typedef struct _PRINTPROCESSOR_CAPS_1 { DWORD
// dwLevel; DWORD dwNupOptions; DWORD dwPageOrderFlags; DWORD dwNumberOfCopies; } PRINTPROCESSOR_CAPS_1, *PPRINTPROCESSOR_CAPS_1;
[PInvokeData("winspool.h", MSDNShortId = "43c568ff-ccc9-4873-b159-ede09b4a7e51")]
[StructLayout(LayoutKind.Sequential)]
public struct PRINTPROCESSOR_CAPS_1
{
/// The structure's version number. This value must be 1.
public uint dwLevel;
///
/// A bit mask representing the various numbers of document pages the printer can print on a physical page. The least
/// significant bit represents 1 document page per page, the next bit represents 2 document pages per page, and so on. For
/// example, 0x0000810B indicates the printer supports 1, 2, 4, 9, and 16 document pages per physical page.
///
public uint dwNupOptions;
/// The order in which pages will be printed. This value can be NORMAL_PRINT, REVERSE_PRINT, or BOOKLET_PRINT.
public uint dwPageOrderFlags;
/// The maximum number of copies the printer can handle.
public uint dwNumberOfCopies;
}
/// Represents printer capability information.
///
///
/// Values for all structure members are supplied by the GetPrintProcessorCapabilities function which is documented in the
/// Windows Driver Kit.
///
///
/// When an application calls GetPrinterData, the spooler calls a print processor's GetPrintProcessorCapabilities
/// function and specifies a value name that has a format of **PrintProcCaps_**datatype, where datatype is the name of an input data type.
///
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printprocessor-caps-2 typedef struct _PRINTPROCESSOR_CAPS_2 { DWORD
// dwLevel; DWORD dwNupOptions; DWORD dwPageOrderFlags; DWORD dwNumberOfCopies; DWORD dwNupDirectionCaps; DWORD dwNupBorderCaps;
// DWORD dwBookletHandlingCaps; DWORD dwDuplexHandlingCaps; DWORD dwScalingCaps; } PRINTPROCESSOR_CAPS_2, *PPRINTPROCESSOR_CAPS_2;
[PInvokeData("winspool.h", MSDNShortId = "70120739-a4e0-4b87-ac7a-40a42fb509ee")]
[StructLayout(LayoutKind.Sequential)]
public struct PRINTPROCESSOR_CAPS_2
{
/// A value that indicates the structure's version number.
public uint dwLevel;
///
/// A bit mask representing the various numbers of document pages the printer can print on a single side of a physical sheet.
/// The least significant bit represents one document page per side, the next bit represents 2 document pages per side, and so
/// on. For example, 0x0000810B indicates the printer supports 1, 2, 4, 9, and 16 document pages per physical side.
///
public uint dwNupOptions;
///
/// A flag value that indicates the order in which pages will be printed. It can be NORMAL_PRINT, REVERSE_PRINT,
/// or BOOKLET_PRINT.
///
public uint dwPageOrderFlags;
/// The maximum number of copies the printer can handle.
public uint dwNumberOfCopies;
///
///
/// The available patterns when multiple document pages are printed on the same side of a sheet of paper. The possible flags are
/// the following:
///
///
///
/// Value
/// Meaning
///
/// -
/// PPCAPS_RIGHT_THEN_DOWN
/// Pages appear in rows from right to left, each subsequent row below its predecessor.
///
/// -
/// PPCAPS_DOWN_THEN_RIGHT
/// Pages appear in columns from top to bottom, each subsequent column to the right of its predecessor.
///
/// -
/// PPCAPS_LEFT_THEN_DOWN
/// Pages appear in rows from left to right, each subsequent row below its predecessor.
///
/// -
/// PPCAPS_DOWN_THEN_LEFT
/// Pages appear in columns from top to bottom, each subsequent column to the left of its predecessor.
///
///
///
public PPCAPS_DIRECTION dwNupDirectionCaps;
///
/// Can be only PPCAPS_BORDER_PRINT, indicating that, when multiple document pages are being printed on a single side of a
/// physical sheet, the printer can be told whether or not to print a border around the imageable area of each document page.
///
public PPCAPS_BORDER dwNupBorderCaps;
/// Can only be PPCAPS_BOOKLET_EDGE, indicating that the printer can print booklet style.
public PPCAPS_EDGE dwBookletHandlingCaps;
///
///
///
/// Value
/// Meaning
///
/// -
/// PPCAPS_REVERSE_PAGES_FOR_REVERSE_DUPLEX
///
/// When printing in reverse order and duplexing, the processor can print swap the order of each pair of pages, so instead of
/// printing in order 4,3,2,1, they will print in the order 3,4,1,2.
///
///
/// -
/// PPCAPS_DONT_SEND_EXTRA_PAGES_FOR_DUPLEX
///
/// When duplexing, the Print Processor can be told not to send an extra page when there is an odd number of document pages. The
/// processor will honor the value as best as it can, but in cases where preventing an extra blank page would cause improper
/// output, the extra pages may still be sent.
///
///
///
///
public PPCAPS_DUPLEX dwDuplexHandlingCaps;
/// Can only be PPCAPS_SQUARE_SCALING, indicating that the printer can scale the page image.
public PPCAPS_SCALING dwScalingCaps;
}
/// The PRINTPROCESSOR_INFO_1 structure specifies the name of an installed print processor.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/printprocessor-info-1 typedef struct _PRINTPROCESSOR_INFO_1 { LPTSTR
// pName; } PRINTPROCESSOR_INFO_1, *PPRINTPROCESSOR_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "49b272c8-156b-4996-b3fd-92cde831f4ae")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PRINTPROCESSOR_INFO_1
{
/// Pointer to a null-terminated string that specifies the name of an installed print processor.
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
}
/// The PROVIDOR_INFO_1 structure identifies a print provider.
// https://docs.microsoft.com/en-us/windows/win32/printdocs/providor-info-1 typedef struct _PROVIDOR_INFO_1 { LPTSTR pName; LPTSTR
// pEnvironment; LPTSTR pDLLName; } PROVIDOR_INFO_1, *PPROVIDOR_INFO_1;
[PInvokeData("winspool.h", MSDNShortId = "0eff115a-b3d2-4c8f-b820-46e7f62dd295")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PROVIDOR_INFO_1
{
/// Pointer to a null-terminated string that is the name of the print provider.
[MarshalAs(UnmanagedType.LPTStr)]
public string pName;
///
/// Pointer to a null-terminated environment string specifying the environment the provider dynamic-link library (DLL) is
/// designed to run in.
///
[MarshalAs(UnmanagedType.LPTStr)]
public string pEnvironment;
/// Pointer to a null-terminated string that is the name of the provider .dll.
[MarshalAs(UnmanagedType.LPTStr)]
public string pDLLName;
}
/// The PROVIDOR_INFO_2 structure appends a print provider to the print provider order list.
///
/// This structure is used when calling AddPrintProvidor, level 2, to add the specified print provider to the end of the
/// print provider order list. The provider is immediately used for routing if the call succeeds.
///
// https://docs.microsoft.com/en-us/windows/win32/printdocs/providor-info-2 typedef struct _PROVIDOR_INFO_2 { LPTSTR pOrder; }
// PROVIDOR_INFO_2, *PPROVIDOR_INFO_2;
[PInvokeData("winspool.h", MSDNShortId = "840523ca-22d0-460f-81fb-e0a9e2d4f5d6")]
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct PROVIDOR_INFO_2
{
/// Pointer to a null-terminated string that specifies the name of the print provider.
[MarshalAs(UnmanagedType.LPTStr)]
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
{
/// Initializes a new instance of the class and assigns an existing handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHPRINTER(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHPRINTER() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HPRINTER(SafeHPRINTER h) => h.handle;
///
protected override bool InternalReleaseHandle() => ClosePrinter(handle);
}
/// Provides a for that is disposed using .
public class SafeHPRINTERCHANGENOTIFICATION : SafeHANDLE, ISyncHandle
{
///
/// Initializes a new instance of the class and assigns an existing handle.
///
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHPRINTERCHANGENOTIFICATION(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { }
/// Initializes a new instance of the class.
private SafeHPRINTERCHANGENOTIFICATION() : base() { }
/// Performs an implicit conversion from to .
/// The safe handle instance.
/// The result of the conversion.
public static implicit operator HPRINTERCHANGENOTIFICATION(SafeHPRINTERCHANGENOTIFICATION h) => h.handle;
///
protected override bool InternalReleaseHandle() => FindClosePrinterChangeNotification(handle);
}
/// Provides a for that is disposed using .
public class SafeHSPOOLFILE : SafeHANDLE
{
private readonly HPRINTER hPrinter;
/// Initializes a new instance of the class and assigns an existing handle.
/// The open printer handle.
/// An object that represents the pre-existing handle to use.
///
/// to reliably release the handle during the finalization phase; otherwise, (not recommended).
///
public SafeHSPOOLFILE(HPRINTER hPrinter, IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) => this.hPrinter = hPrinter;
/// 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 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);
}
///
/// Represents the system allocated pointer to created by the
/// function.
///
///
public class SafePRINTER_NOTIFY_INFO : SafeHANDLE
{
private SafePRINTER_NOTIFY_INFO() : base()
{
}
/// Performs an implicit conversion from to .
/// The h.
/// The result of the conversion.
public static implicit operator PRINTER_NOTIFY_INFO(SafePRINTER_NOTIFY_INFO h) => h.IsInvalid ? default : h.handle.ToStructure();
///
/// Internal method that actually releases the handle. This is called by
/// for valid handles and afterwards zeros the handle.
///
/// true to indicate successful release of the handle; false otherwise.
protected override bool InternalReleaseHandle() => FreePrinterNotifyInfo(handle);
}
internal class PRINTER_DEFAULTS_Marshaler : ICustomMarshaler
{
/// Gets the instance.
/// The cookie.
/// An instance of this class.
public static ICustomMarshaler GetInstance(string _) => new PRINTER_DEFAULTS_Marshaler();
public void CleanUpManagedData(object ManagedObj) => throw new NotImplementedException();
public void CleanUpNativeData(IntPtr pNativeData) => Marshal.FreeCoTaskMem(pNativeData);
public int GetNativeDataSize() => -1;
public IntPtr MarshalManagedToNative(object ManagedObj)
{
if (!(ManagedObj is PRINTER_DEFAULTS pd)) throw new ArgumentException("Type of managed object must be PRINTER_DEFAULTS.");
var sz = IntPtr.Size * 2 + 4 + StringHelper.GetByteCount(pd.pDatatype) + (pd.pDevMode?.dmSize ?? 0);
var mem = new SafeCoTaskMemHandle(sz);
using (var str = new NativeMemoryStream(mem))
{
str.WriteReference(pd.pDatatype);
str.WriteReferenceObject(pd.pDevMode.HasValue ? (object)pd.pDevMode.Value : null);
str.Write((uint)pd.DesiredAccess);
}
return mem.TakeOwnership();
}
public object MarshalNativeToManaged(IntPtr pNativeData) => throw new NotImplementedException();
}
/*
DOCEVENT_CREATEDPRE
DOCEVENT_ESCAPE
DOCEVENT_CREATEDPRE
DOCEVENT_FILTER
*/
}
}