《看到一个VB打印模块,保存一下》由会员分享,可在线阅读,更多相关《看到一个VB打印模块,保存一下(22页珍藏版)》请在金锄头文库上搜索。
1、看到一个 VB 打印模块 ,保存一下 模块 modPrintOption ExplicitPublic Declare Function EnumForms Lib winspool.drvAlias EnumFormsA _(ByVal hPrinter As Long, ByVal Level As Long, ByRef pForm As Any, _ByVal cbBuf As Long, ByRef pcbNeeded As Long, _ByRef pcReturned As Long) As LongPublic Declare Function AddForm Lib wins
2、pool.drv Alias AddFormA _(ByVal hPrinter As Long, ByVal Level As Long, pFormAs Byte) As LongPublic Declare Function DeleteForm Lib winspool.drvAlias DeleteFormA _(ByVal hPrinter As Long, ByVal pFormName As String)As LongPublic Declare Function OpenPrinter Lib winspool.drv _Alias OpenPrinterA (ByVal
3、pPrinterName As String, phPrinter As Long, ByVal pDefault As Long) As LongPublic Declare Function ClosePrinter Lib winspool.drv _(ByVal hPrinter As Long) As LongPublic Declare Function DocumentProperties Lib winspool.drv _Alias DocumentPropertiesA (ByVal hwnd As Long,ByVal hPrinter As Long, ByVal pD
4、eviceName As String, _pDevModeOutput As Any, pDevModeInput As Any, ByVal fMode As Long) _As LongPublic Declare Function ResetDC Lib gdi32 Alias ResetDCA _(ByVal hdc As Long, lpInitData As Any) As Long Public Declare Sub CopyMemory Lib kernel32 Alias RtlMoveMemory _(hpvDest As Any, hpvSource As Any,
5、ByVal cbCopy As Long)Public Declare Function lstrcpy Lib kernel32 Alias lstrcpyA _(ByVal lpString1 As String, ByRef lpString2 As Long) As Long Optional functions not used in this sample, but may be useful.Public Declare Function GetForm Lib winspool.drv Alias GetFormA _(ByVal hPrinter As Long, ByVal
6、 pFormName As String,ByVal Level As Long, pForm As Byte, ByVal cbBuf As Long, _pcbNeeded As Long) As LongPublic Declare Function SetForm Lib winspool.drv Alias SetFormA _(ByVal hPrinter As Long, ByVal pFormName As String,ByVal Level As Long, pForm As Byte) As Long Constants for DEVMODEPublic Const C
7、CHFORMNAME = 32Public Const CCHDEVICENAME = 32Public Const DM_FORMNAME As Long = &H10000Public Const DM_ORIENTATION = &H1& Constants for PRINTER_DEFAULTS.DesiredAccessPublic Const PRINTER_ACCESS_ADMINISTER = &H4Public Const PRINTER_ACCESS_USE = &H8Public Const STANDARD_RIGHTS_REQ
8、UIRED = &HF0000Public Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or _PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE) Constants for DocumentProperties() call Public Const DM_MODIFY = 8 Public Const DM_IN_BUFFER = DM_MODIFY Public Const DM_COPY = 2 Public Const DM_OUT_BUFFER = DM_COPY C
9、ustom constants for this samples SelectForm function Public Const FORM_NOT_SELECTED = 0 Public Const FORM_SELECTED = 1 Public Const FORM_ADDED = 2 Public Type RECTLLeft As Long Top As Long Right As Long Bottom As LongEnd TypePublic Type SIZEcx As Longcy As LongEnd TypePublic Type SECURITY_DESCRIPTOR
10、Revision As ByteSbz1 As ByteControl As LongOwner As LongGroup As LongSacl As Long ACLDacl As Long ACLEnd Type The two definitions for FORM_INFO_1 make the coding easier.Public Type FORM_INFO_1Flags As LongpName As Long StringSize As SIZEL ImageableArea As RECTLEnd TypePublic Type sFORM_INFO_1Flags A
11、s Long pName As String Size As SIZEL ImageableArea As RECTLEnd TypePublic Type DEVMODEdmDeviceName As String * CCHDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength A
12、s Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As IntegerdmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCHFORMNAME dmUnusedPadding As Integer dmBits
13、PerPel As Long dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As LongEnd TypePublic Type PRINTER_DEFAULTSpDatatype As String pDevMode As Long DEVMODE DesiredAccess As LongEnd TypePublic Type PRINTER_INFO_2 pServerName As String pPrinterName As String pShareName As
14、 String pPortName As String pDriverName As StringpComment As String pLocation As String pDevMode As DEVMODE pSepFile As String pPrintProcessor As String pDatatype As String pParameters As String pSecurityDescriptor As SECURITY_DESCRIPTORAttributes As Long Priority As Long DefaultPriority As Long Sta
15、rtTime As Long UntilTime As Long Status As Long cJobs As Long AveragePPM As Long End Type 判断系统是否为 NT 系统 Public Declare Function GetVersionEx Lib kernel32 Alias GetVersionExA _(lpVersionInformation AsOSVERSIONINFO) As Long Public Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 Maintenance string for PSS usageEnd TypePublic Function SelectForm(FormName As String, ByValMyhWnd As Long) _As Integer