473,396 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

LPT1 printer dilema

Hi guys,

I have an old VB app that writes just fine to an old LPT printer. I do
this using:

Open "LPT1" ....
Now, the app is changing and I have to do the same thing in .NET. I
found at http://support.microsoft.com/?id=322090 a sample. It works fine
with any network printer, but not with the LPT1 printer... This is the
code it uses, and I get NO error messages with LPT1. Everything looks
fine, except that it doesn't work (bSuccess even returns True):
If OpenPrinter(szPrinterName, hPrinter, 0) Then
If StartDocPrinter(hPrinter, 1, di) Then
If StartPagePrinter(hPrinter) Then
' Write your printer-specific bytes to the printer.
bSuccess = WritePrinter(hPrinter, pBytes, dwCount,
dwWritten)
EndPagePrinter(hPrinter)
End If
EndDocPrinter(hPrinter)
End If
ClosePrinter(hPrinter)
End If
Then I found this sample:
http://support.microsoft.com/default...79&Product=vb6.

hParallelPort = CreateFile("LPT1", GENERIC_READ Or GENERIC_WRITE, 0,
IntPtr.Zero, _
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero)
' Verify that the obtained handle is valid.
If hParallelPort.ToInt32 = -1 Then
Throw New CommException("Unable to obtain a handle to
the LPT1 port")
End If
' Retrieve the current control settings.
Success = GetCommState(hParallelPort, MyDCB)
If Success = False Then
Throw New CommException("Unable to retrieve the current
control settings")
End If

This one returns Success = False. It looks like .NET can't communicate
with the LPT1 port, even though VB6 can.

Does anyone have any idea what's wrong here ?? ALL the samples I found
on the net do pretty much the same thing that I did. Any help would be
greatly appreciated. Thanks a lot
Jul 21 '05 #1
0 1703

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chuck Rittersdorf | last post by:
Hi There I am having a problem using the win32 API from VB6. I am trying to send a command string to a printer(zebra TLP 2742) on LPT1 using the folowing API functions CreateFile and...
1
by: Allan | last post by:
I open and write LPT1 as file with standart file i/o functions. But it sends directly to the printer on win98 without spooling.But when I send something from command prompt (dos) to LPT1 it is...
0
by: Ales Vojacek | last post by:
hi, can you help me with direct output to LPT1:? When I try to create TextWriter to lpt1: it fell with error. Thank you. Ales Sorry for my English
5
by: Tom | last post by:
I am converting an old application that was printing directly to a specialized printer device (i.e. a special label printer). It was doing this by opening a file with the file path of 'LPT1:' and...
1
by: Luis Ramos | last post by:
Hello, In VB6 i use to print text to the lpt1 port, because of matricial printers and i use to do this: open "lpt1:" for output as #1 print #1, "some text" close #1 my question is: How can i...
0
by: Nick | last post by:
Hi guys, I have an old VB app that writes just fine to an old LPT printer. I do this using: Open "LPT1" .... Now, the app is changing and I have to do the same thing in .NET. I found at...
3
by: nimmiejoey | last post by:
Hello everybody, could you please tell me the meaning of the command outport(LPT1,00)
0
by: realgoggi | last post by:
Hello, I have a label printer connected to LPT1 on the server where IIS and the ASPX/C# code is running. From the web application I need to send data to the printer. Preferably directly,...
1
by: widevision7 | last post by:
I use FedEx's online shipping web site via Internet Explorer to print FedEx shipping labels. But, the FedEx site only allows printing to a LTP1 or COM port, and I have a USB printer. I can use...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.