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