473,386 Members | 1,610 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,386 software developers and data experts.

REPOST: C# Guru's! ReadPrinter....I need to read printer buffer to stringbuilder...

The WritePrinter() is working. I know this ReadPrinter()
implementation isn't correct because it never reads into "reaDstrinG"
buffer from the printer...But, I'm sure one of you Guru's do know how I

can make this work (and any help is appreciated):

sb = new StringBuilder(initialValue);

PrintDirect.OpenPrinter(@"\\Web1\Shipping1",ref lhPrinter,0);
for (int i = -1; i < 23; i++)
{
PrintDirect.ReadPrinter(lhPrinter, sb = sb.Insert(3, reaDstrinG),
buf, out pcRead);
}
___________________________-

[ DllImport( "winspool.drv",CharSet=CharSet.Ansi,ExactSpelling= true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool ReadPrinter(IntPtr hPrinter, StringBuilder
data, int buf, out int pcRead);
And still, ReadPrinter is not working at all.

Mattias wrote this:
Use bool as the return type and make the data parameter a
StringBuilder
and...
public static extern bool ReadPrinter(IntPtr hPrinter, StringBuilder
data, int buf, out int pcRead);

Any help is appreciated.
Trint

Nov 16 '05 #1
6 7452
Not sure what you are expecting to read from a printer (you are NOT reading
from a printer job!!).
Anyway you don't check the return from the ReadPrinter API, so you and we
can't tell what went wrong. But I'm pretty sure you can't read from a
printer over the network, nor can you read from a uni-directional printer.

Willy.
"trint" <tr***********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
The WritePrinter() is working. I know this ReadPrinter()
implementation isn't correct because it never reads into "reaDstrinG"
buffer from the printer...But, I'm sure one of you Guru's do know how I

can make this work (and any help is appreciated):

sb = new StringBuilder(initialValue);

PrintDirect.OpenPrinter(@"\\Web1\Shipping1",ref lhPrinter,0);
for (int i = -1; i < 23; i++)
{
PrintDirect.ReadPrinter(lhPrinter, sb = sb.Insert(3, reaDstrinG),
buf, out pcRead);
}
___________________________-

[ DllImport( "winspool.drv",CharSet=CharSet.Ansi,ExactSpelling= true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool ReadPrinter(IntPtr hPrinter, StringBuilder
data, int buf, out int pcRead);
And still, ReadPrinter is not working at all.

Mattias wrote this:
Use bool as the return type and make the data parameter a
StringBuilder
and...
public static extern bool ReadPrinter(IntPtr hPrinter, StringBuilder
data, int buf, out int pcRead);

Any help is appreciated.
Trint

Nov 16 '05 #2
Yeah! you can read this printer on a network. I have a program that
came with it that reads it's supplies level down to the staples in the
cartridge.
Here is what I send to the printer and then must receive back it's
response:

st1 = "\x1b%-12345X@PJL \f" +
"@PJL COMMENT ***Inquiring About \f" +
"@PJL COMMENT Environment Settings*** \f" +
@"@PJL ECHO " + formaTtd + " \f" +
"@PJL INQUIRE INTRAY2 \f" +
"@PJL INQUIRE INTRAY3 \f" +
"@PJL INQUIRE INTRAY4 \f" +
"@PJL INQUIRE STAPLER \f" +
"@PJL INQUIRE TONNER \f" +
"@PJL INQUIRE TIMEOUT \f" +
"@PJL ENTER LANGUAGE=PCL \f" +
"\x1b%-12345X\f";

PrintDirect.OpenPrinter(@"HP LaserJet 4250 PCL 6",ref lhPrinter,0);
PrintDirect.WritePrinter(lhPrinter,st1,st1.Length, ref pcWritten);
PrintDirect.ClosePrinter(lhPrinter);

And somehow, I have to make the following code work or similar code:

char[]thisMightbeIt;
int buf = 0;
int pcRead;
System.Text.StringBuilder sb = new System.Text.StringBuilder();

PrintDirect.OpenPrinter(@"HP LaserJet 4250 PCL 6",ref lhPrinter,0);
for (int i = -1; i < 23; i++)
{
PrintDirect.ReadPrinter(lhPrinter, sb.Append(thisMightbeIt[i],100),
buf, out pcRead);

}

Thanks for an help on this!
Trint

..Net programmer
tr***********@gmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3

"Trint Smith" <tr***********@gmail.com> wrote in message
news:e9**************@TK2MSFTNGP09.phx.gbl...
Yeah! you can read this printer on a network. I have a program that
came with it that reads it's supplies level down to the staples in the
cartridge.
Here is what I send to the printer and then must receive back it's
response:

st1 = "\x1b%-12345X@PJL \f" +
"@PJL COMMENT ***Inquiring About \f" +
"@PJL COMMENT Environment Settings*** \f" +
@"@PJL ECHO " + formaTtd + " \f" +
"@PJL INQUIRE INTRAY2 \f" +
"@PJL INQUIRE INTRAY3 \f" +
"@PJL INQUIRE INTRAY4 \f" +
"@PJL INQUIRE STAPLER \f" +
"@PJL INQUIRE TONNER \f" +
"@PJL INQUIRE TIMEOUT \f" +
"@PJL ENTER LANGUAGE=PCL \f" +
"\x1b%-12345X\f";

PrintDirect.OpenPrinter(@"HP LaserJet 4250 PCL 6",ref lhPrinter,0);
PrintDirect.WritePrinter(lhPrinter,st1,st1.Length, ref pcWritten);
PrintDirect.ClosePrinter(lhPrinter);

And somehow, I have to make the following code work or similar code:

char[]thisMightbeIt;
int buf = 0;
int pcRead;
System.Text.StringBuilder sb = new System.Text.StringBuilder();

PrintDirect.OpenPrinter(@"HP LaserJet 4250 PCL 6",ref lhPrinter,0);
for (int i = -1; i < 23; i++)
{
PrintDirect.ReadPrinter(lhPrinter, sb.Append(thisMightbeIt[i],100),
buf, out pcRead);

}

Thanks for an help on this!
Trint

Net programmer
tr***********@gmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


I didnt say you can't read from a printer, I said you cannot read from a
uni-directional printer and probably not from a networked printer.
And most importantly, you are not checking your return from the ReadPrinter
call how the hell would you want us to tell you why it's not working.
Second, the example you are posting now is reading from a local attached
printer ((@"HP LaserJet 4250 PCL 6"), while in the original post you are
refering to a networked printer ((@"\\Web1\Shipping1",) quite a difference
isn't it?

Note also that you can query the information you are looking for through the
System.Management namespace classes and the WMI win32_printer class.
Willy.
Nov 16 '05 #4
I was just testing my code with a usb.

.Net programmer
tr***********@gmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #5

"Trint Smith" <tr***********@gmail.com> wrote in message
news:OD****************@TK2MSFTNGP12.phx.gbl...
I was just testing my code with a usb.


And what does this mean, is it working or not?
Does it mean it works when you run the code on the box to which the printer
is physically attached?
And that it fails if you run the code on another box using
(@"\\Web1\Shipping1... as printer name in the OpenPrinter call?

Willy.
Nov 16 '05 #6
No, it doesn't work yet. But I'm currently working on that.

.Net programmer
tr***********@gmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #7

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

Similar topics

11
by: Mike Cox | last post by:
After writing an article trashing java, and C++, notable LISP guru Paul Graham is getting roasted on slashdot. Apart from AutoCAD and Emacs, what has LISP done anyway? Most real work is done in...
4
by: Accolo1 | last post by:
Help we are looking for this person, do you know them? William wjohnson@accolo.com Title: BEA WebLogic Portal Guru Job #: 03-04468 Check the pulse of your career! Evolve our eCommerce web...
3
by: Adam | last post by:
I've posted about this previously, but failed to receive a satisfactory response, so have included a code sample: I am trying to receive messages from an HTML viewer control in compact.net (c#),...
14
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant...
67
by: Scott M. | last post by:
Can anyone give me any ideas on why VS.NET 2003 running on XP Pro. (P4's with 1GB RAM) would take over 3 minutes to simply create a new ASP.NET Web Application on http://localhost? It seems that...
2
by: Gerry | last post by:
I have a combo box and I can populate it with my class of dat (the class allows me to store each userid,username called - see code below I want the user to select the dropdown and see the...
2
by: Raj | last post by:
Hi, I have the following problem. I am displaying and printing a PDF file that is generated by my Application server. The print dialogs comes up correctly for the small PDF for the larger PDFs...
3
by: Michael Suess | last post by:
Hi, please feel free to correct me if this is the wrong group to ask this question. I have a blog about parallel programming and concurrency (http://www.thinkingparallel.com if you are...
16
by: Singulus | last post by:
Hello all, I've searched for similar threads, I've found some bit of useful info here and there, but nevertheless I want to post my questions...So, how can I (we, in fact the forum can benefit...
1
by: stevenjs | last post by:
Greeings, all, Flash 8 has quiz templates which are coded for multiple choice, true/false, text statement, and matching types of questions, along with hotspots and probably anoher type I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.