Can anyone help with ReadPrinter using winspool.drv?

T

trint

I need to read ascii coming from my printer. It needs to be something
like this:

System.IntPtr lhPrinter=new System.IntPtr();
DOCINFO di = new DOCINFO();
int pcWritten=0;
int pcRead=0;
string st1;

if(readResult = (! PrintDirect.ReadPrinter(
lhPrinter,st1,st1.Length,ref pcRead) ))
{
listBox2.Items.Add(st1);
}

public class PrintDirect: Form1
{
[ DllImport( "winspool.drv",CharSet=CharSet.Ansi,ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool ReadPrinter(IntPtr hPrinter,string data,
int buf,ref int pcRead);

Am I even close?
Thanks,
Trint
 
M

Mattias Sjögren

Am I even close?

You should use OpenPrinter to get the printer handle. And the second
parameter to ReadPrinter should be a StringBuilder if it's an output
string buffer.



Mattias
 
T

Trint Smith

Mattias,
I am going to try your suggestion right now.
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
T

Trint Smith

Mattias,
I looked at some stringbuilder samples and just don't get it. I think I
need more info from winspool.drv...it's really hard to find out ANYTHING
from Microsoft.
Any help is appreciated.
Thanks,
Trint

..Net programmer
(e-mail address removed)
 
W

Willy Denoyette [MVP]

Trint Smith said:
Mattias,
I looked at some stringbuilder samples and just don't get it. I think I
need more info from winspool.drv...it's really hard to find out ANYTHING
from Microsoft.
Any help is appreciated.
Thanks,
Trint

Not sure where you are looking, MSDN - .NET Framework Developer's Guide
contains hundred of samples, start reading here: Using the StringBuilder
Class
And no, you don't need winspoll.drv.

Willy.
 
T

Trint Smith

Thanks,
I'm checking that out right now.
Trint

..Net programmer
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top