???? ID: 154078 - ????? ???????: 02 ?????? 2010 - ??????: 4.0

?????? ???? ?? ???? ??????? ?? Visual Basic Win32 API ?? ????? ???? ?? ??? ????? ???? ????

?????? ??????This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
??? ?? ??????? ???? | ??? ?? ??????? ????

??????

??????? ??????? ?? ?????? ?? ?????? ???? ?? ??? Visual Basic ??????? ???????? ?? ?????? ???? ??, ????? ?? ?? ?? ???? ??????? ?? ??????? ????? ?? ??? Win32 API ?? ????? ???? ?? ??? desirable ??? ?? ???? ??? ??? ????? ?? ???? ???? ?? ??? ?????? ?????? ?? ????? ???? ?? ??? ??????? ??????? ?? ?????? API ?????? ?? ????? ?? ?? ????? ???? ?? ??? ???? ?????? ???

???? ???????

  1. Visual Basic ??? ??? ??? ????????? ??????? ????? Form1 ???????? ??? ?? ???? ??..
  2. ??? ???? ??? ?? ??????? ?? ?????
  3. Form1 ??? ????? ??? ????? ??? ??????:
          Option Explicit
    
          Private Type DOCINFO
              pDocName As String
              pOutputFile As String
              pDatatype As String
          End Type
    
          Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _
             hPrinter As Long) As Long
          Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _
             hPrinter As Long) As Long
          Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _
             hPrinter As Long) As Long
          Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
             "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
              ByVal pDefault As Long) As Long
          Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _
             "StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
             pDocInfo As DOCINFO) As Long
          Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _
             hPrinter As Long) As Long
          Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _
             hPrinter As Long, pBuf As Any, ByVal cdBuf As Long,  _
             pcWritten As Long) As Long
    
          Private Sub Command1_Click()
              Dim lhPrinter As Long
              Dim lReturn As Long
              Dim lpcWritten As Long
              Dim lDoc As Long
              Dim sWrittenData As String
              Dim MyDocInfo As DOCINFO
              lReturn = OpenPrinter(Printer.DeviceName, lhPrinter, 0)
              If lReturn = 0 Then
                  MsgBox "The Printer Name you typed wasn't recognized."
                  Exit Sub
              End If
              MyDocInfo.pDocName = "AAAAAA"
              MyDocInfo.pOutputFile = vbNullString
              MyDocInfo.pDatatype = vbNullString
              lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
              Call StartPagePrinter(lhPrinter)
              sWrittenData = "How's that for Magic !!!!" & vbFormFeed
              lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
                 Len(sWrittenData), lpcWritten)
              lReturn = EndPagePrinter(lhPrinter)
              lReturn = EndDocPrinter(lhPrinter)
              lReturn = ClosePrinter(lhPrinter)
          End Sub
    
    						

??????

Win32 SDK ?????? ???????, APIs ????? ??? ????? ?? ???? ??????? ????? ????

??????? ?? ??? ?? ?? ????????? VC ++ ?? ???, ????? ????? ???? ?? Microsoft ???????? ??? ?????:
138594  (http://support.microsoft.com/kb/138594/EN-US/ ) : ???? Win32 API ?? ????? ?? ???? ??????? ?? ??? ?????? ???? ?????

???? ???? ???? ??:
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic 4.0 Standard Edition
??????: 
kbapi kbhowto kbprint kbmt KB154078 KbMthi
???? ?????? ???????????? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:154078  (http://support.microsoft.com/kb/154078/en-us/ )