Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

RawPrinterHelper

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nir - 04 Jan 2005 15:55 GMT
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.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.