Hello ,
I have problem with printing using below code to my printer ,
anyone have any idea why this Code is not working .
I have WinXP SP1
Public Class clsRawPrinterHelper
Private Structure DOCINFO
Public pDocName As String
Public pOutputFile As String
Public pDatatype As String
End Structure
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, ByVal 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, ByVal
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, ByVal pBuf As Object, ByVal cdBuf As Long, ByVal
pcWritten As Long) As Long
Public Sub LetsTry(ByVal asDoc As String)
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("FaxJob", lhPrinter, 0)
If lReturn = 0 Then
MsgBox("The Printer Name you typed wasn't recognized.")
Exit Sub
End If
MyDocInfo.pDocName = asDoc
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)
sWrittenData = Chr(27) & "[B9187686" & Chr(27) & "[D5152535" &
Chr(27) & "[NNir" & Chr(27) & "[MTest" & Chr(27) & "[P3" & Chr(27) &
"[Omsg" & Chr(27) & "[Smsg" & Chr(27) & "[R" & Chr(27) & "]"
lReturn = WritePrinter(lhPrinter, sWrittenData,
Len(sWrittenData), lpcWritten)
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)
End Sub
End Class
Mattias Sj?gren - 05 Jan 2005 22:23 GMT
>anyone have any idea why this Code is not working .
Because you're using what looks like VB6 Declare statements. See if
you can find working VB.NET equivalents at http://www.pinvoke.net
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.