'モジュール Public Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" _ (ByVal PrinterName As String, ByRef hPrinter As IntPtr, ByVal pDefault As PRINTER_DEFAULTS) As Boolean Public Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" _ (ByVal hPrinter As IntPtr, ByVal dwLevel As Integer, _ ByVal pPrinter As IntPtr, ByVal cbBuf As Integer, ByRef pcbNeeded As Integer) As Boolean Public Declare Sub CopyMemory1 Lib "KERNEL32" Alias "RtlMoveMemory" _ (ByVal hpvDest As DEVMODE, ByVal hpvSource As IntPtr, ByVal cbCopy As Long) Public Declare Sub CopyMemory2 Lib "KERNEL32" Alias "RtlMoveMemory" _ (ByVal hpvDest As IntPtr, ByVal hpvSource As DEVMODE, ByVal cbCopy As Long) Public Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal hPrinter As IntPtr, _ ByVal Level As Integer, ByRef pPrinter As PRINTER_INFO_2, ByVal Command_Renamed As Integer) As Boolean Public Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Boolean Public Structure PRINTER_DEFAULTS Public pDatatype As String Public pDevMode As Long Public DesiredAccess As Long End Structure Public Structure PRINTER_INFO_2 Public pServerName As String Public pPrinterName As String Public pShareName As String Public pPortName As String Public pDriverName As String Public pComment As String Public pLocation As String Public pDevMode As IntPtr Public pSepFile As String Public pPrintProcessor As String Public pDatatype As String Public pParameters As String Public pSecurityDescriptor As IntPtr Public Attributes As System.UInt32 Public Priority As System.UInt32 Public DefaultPriority As System.UInt32 Public StartTime As System.UInt32 Public UntilTime As System.UInt32 Public Status As System.UInt32 Public cJobs As System.UInt32 Public AveragePPM As System.UInt32 End Structure Public Const CCHFORMNAME = 32 Public Const CCHDEVICENAME = 32 Public Structure DEVMODE <VBFixedString(CCHDEVICENAME)> Public dmDeviceName As String Public dmSpecVersion As Integer Public dmDriverVersion As Integer Public dmSize As Integer Public dmDriverExtra As Integer Public dmFields As Long Public dmOrientation As Integer Public dmPaperSize As Integer Public dmPaperLength As Integer Public dmPaperWidth As Integer Public dmScale As Integer Public dmCopies As Integer Public dmDefaultSource As Integer Public dmPrinterQuality As Integer Public dmColor As Integer Public dmDuplex As Integer Public dmYResolution As Integer Public dmTTOption As Integer Public dmCollate As Integer <VBFixedString(CCHFORMNAME)> Public dmFormname As String Public dmUnusedPadding As Integer Public dmBitsPerPel As Integer Public dmPelsWidth As Long Public dmPelsHeight As Long Public dmDisplayFlags As Long Public dmDisplayFrequency As Long End Structure Public Const DMORIENT_PORTAIT = 1 Public Const STANDARD_RIGHTS_REQUIRED = &HF0000 Public Const PRINTER_ACCESS_ADMINISTER = &H4 Public Const PRINTER_ACCESS_USE = &H8 Public Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE) Public Const DM_PAPERSIZE = &H2 'dmPaperSize Public Const DM_PAPERLENGTH = &H4 'dmPaperLength Public Const DM_PAPERWIDTH = &H8 'dmPaperWidth