'モジュール Public Type PRINTER_DEFAULTS pDatatype As String pDevMode As Long DesiredAccess As Long End Type 'http://www.winapi-database.com/Struct/DEVMODE.html Public Const CCHFORMNAME = 32 Public Const CCHDEVICENAME = 32 Public Type DEVMODE dmDeviceName As String * CCHDEVICENAME 'デバイス名の文字列 dmSpecVersion As Integer 'DEVMODEのバージョン(Win3.1 = &H30A) dmDriverVersion As Integer 'ドライバのバージョン dmSize As Integer 'DEVMODE構造体のバイト数 dmDriverExtra As Integer 'DEVMODE構造体に続くデータのバイト数 dmFields As Long 'DEVMODE構造体の有効なエントリ数を指定 dmOrientation As Integer '用紙の向きを指定する定数 dmPaperSize As Integer '用紙サイズ dmPaperLength As Integer '用紙の長さ(10mm単位)(dmPaperSizeに優先) dmPaperWidth As Integer '用紙の幅(10mm単位)(dmPaperSizeに優先) dmScale As Integer '用紙の拡大倍率(x/100単位) dmCopies As Integer 'コピー数 dmDefaultSource As Integer 'デフォルトのピン番号 dmPrinterQuality As Integer '印刷品質 dmColor As Integer 'カラーモード dmDuplex As Integer '両面印刷の設定 dmYResolution As Integer 'Y方向の印刷品質(Dot/inch) dmTTOption As Integer 'TrueTypeフォントの印刷方法 dmCollate As Integer 'ページそろえの設定 dmFormname As String * CCHFORMNAME 'フォーム名(WindowsNT系のみ) dmUnusedPadding As Integer '未使用 dmBitsPerPel As Integer 'ピクセルあたりのビット数 dmPelsWidth As Long '幅(単位:ピクセル) dmPelsHeight As Long '高さ(単位:ピクセル) dmDisplayFlags As Long 'ディスプレイモードを指定する定数 dmDisplayFrequency As Long 'ディスプレイの動作周波数 End Type Public Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" _ (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long Public Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" _ (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal Command As Long) As Long Public Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" _ (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal cbBuf As Long, pcbNeeded As Long) As Long Public Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long) Public Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long 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