Can anyone help with ReadPrinter using winspool.drv?

  • Thread starter Thread starter trint
  • Start date Start date
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
 
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
 
Mattias,
I am going to try your suggestion right now.
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
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)
 
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.
 
Thanks,
I'm checking that out right now.
Trint

..Net programmer
(e-mail address removed)
 
Back
Top