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 / Windows Forms / WinForm General / January 2007

Tip: Looking for answers? Try searching our database.

Is .NET no good for some things?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Angus - 12 Jan 2007 17:19 GMT
It used to be simple in Basic to "open" a printer (like LPT1), then "write" ASCII characters to it. Alternatively, one could create a text-file, then a simple DOS copy operation could copy the text file to a printer using shell. There is no documentation to indicate how this might still be accomplished

Does anybody know if one can still "copy" a file to a windows printer i.e. use shell to dump a text file to a device (e.g. \\main\HP Laser  which might be a printer attached to one of the nodes of the network or perhaps to 192.168.1.20 which might be the IP address for a network printer)? I believe copy can still be done if one maps a device to LPT1 or something. However, I'm not sure about how to do this using the network name or the IP address of the printer if it is not connected as a shared resource of a PC

Thanks and have a great day!

Bill Angus, MA
http://www.psychtest.com
RobinS - 12 Jan 2007 17:45 GMT
Try this link. This shows how to use RawPrinting.

http://support.microsoft.com/?id=322090

BTW, please post your messages in text format; not everybody's
newsreader handles html.

Thanks,
Robin S.
------------------------------
It used to be simple in Basic to "open" a printer (like LPT1), then
"write" ASCII characters to it. Alternatively, one could create a
text-file, then a simple DOS copy operation could copy the text file to
a printer using shell. There is no documentation to indicate how this
might still be accomplished

Does anybody know if one can still "copy" a file to a windows printer
i.e. use shell to dump a text file to a device (e.g. \\main\HP Laser
which might be a printer attached to one of the nodes of the network or
perhaps to 192.168.1.20 which might be the IP address for a network
printer)? I believe copy can still be done if one maps a device to LPT1
or something. However, I'm not sure about how to do this using the
network name or the IP address of the printer if it is not connected as
a shared resource of a PC

Thanks and have a great day!

Bill Angus, MA
http://www.psychtest.com
Bill Angus - 13 Jan 2007 00:08 GMT
GREAT: THANKS V. MUCH !!

Bill Angus
----- Original Message -----
From: RobinS
Newsgroups: microsoft.public.dotnet.framework.windowsforms
Sent: Friday, January 12, 2007 9:45 AM
Subject: Re: Is .NET no good for some things?

Try this link. This shows how to use RawPrinting.

http://support.microsoft.com/?id=322090

BTW, please post your messages in text format; not everybody's
newsreader handles html.

Thanks,
Robin S.
RobinS - 13 Jan 2007 00:30 GMT
I got that from Tim Patrick's start-to-finish vb2005 book; he has an
example of how to use it in his book, and references the article on
msdn.
I hope it helps.

Robin S.
-----------------------------------
> GREAT: THANKS V. MUCH !!
>
[quoted text clipped - 14 lines]
> Thanks,
> Robin S.
Bill Angus - 14 Jan 2007 20:49 GMT
One question: When you used this code how did you get around the following
error ...

A call to PInvoke function
'ProfitMaster!PM_Namspace.PM_Module+RawPrinterHelper::OpenPrinter' has
unbalanced the stack. This is likely because the managed PInvoke signature
does not match the unmanaged target signature. Check that the calling
convention and parameters of the PInvoke signature match the target
unmanaged signature.

which occurs when the following line of code is accessed ....

If OpenPrinter(szPrinterName, hPrinter, 0) Then ...

--
Thanks and have a great day!

Bill Angus, MA
http://www.psychtest.com
RobinS - 15 Jan 2007 00:11 GMT
I got this from Tim Patrick's book and it just works for me. I printed
out the article and looked at the changes. He uses it almost
identically,
except for a few changes.

He changed the routine SendBytesToPrinter. He renamed it
SendStringToPrinter. Here's the header:

Public Shared Function SendStringToPrinter(ByVal targetPrinter As
String, _
 ByVal stringContent As String, ByVal documentTitle As String) as
Boolean

He added the following definitions at the top:

 Dim contentBytes as IntPtr
 Dim contentSize as Int32

Before the line that initializes bSuccess = False, he added this:

 'Convert the string to ANSI text.
 contentSize = stringContent.Length()
 contentBytes = Marshal.StringToCoTaskMemAnsi(stringContent)

After "Write your printer-specific bytes to the printer" the article
has this:  bSuccess = WritePrinter(hPrinter, pBytes, dwCount, dwWritten)
but Tim has this:

 bSuccess = WritePrinter(hPrinter, contentByes, contentSize, dwWritten)

Then at the end before returning bSuccess, he has

 'Free up unused memory.
 Marshal.FreeCoTaskmem(contentBytes)

This was a VB2005 book, and I don't know if the changes had something
to do with that, or because the MSDN article didn't work exactly right.

Does this help?

Robin S.
----------------------------------------------

> One question: When you used this code how did you get around the
> following
[quoted text clipped - 17 lines]
> Bill Angus, MA
> http://www.psychtest.com
Bill Angus - 15 Jan 2007 23:52 GMT
You've been a big help Robin. I've ordered the book since you found a
solution to the problem in it and it works for you. There may be some
confusion in the email below, because there must be more or different
changes that the ones you listed.

Thanks again.

> I got this from Tim Patrick's book and it just works for me. I printed
> out the article and looked at the changes. He uses it almost
[quoted text clipped - 60 lines]
> > Bill Angus, MA
> > http://www.psychtest.com
RobinS - 16 Jan 2007 06:08 GMT
I hope it helps you. He's using it to print bar codes, which
I thought was pretty cool.  He also puts his e-mail address
in the book, and if you can't get it to work right, try
e-mailing him and see if he has any more detail that would help.

Robin S.
--------------------
> You've been a big help Robin. I've ordered the book since you found a
> solution to the problem in it and it works for you. There may be some
[quoted text clipped - 73 lines]
>> > Bill Angus, MA
>> > http://www.psychtest.com

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.