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

Can anyone help with ReadPrinter using winspool.drv?

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

Nov 16 '05 #1
5 7011
>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 Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
Mattias,
I am going to try your suggestion right now.
Thanks,
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
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
tr***********@gmail.com

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

"Trint Smith" <tr***********@gmail.com> wrote in message
news:eU**************@TK2MSFTNGP09.phx.gbl...
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.
Nov 16 '05 #5
Thanks,
I'm checking that out right now.
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 #6

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

Similar topics

4
by: Umesh | last post by:
Hi all I am trying to change the printer(like paper source ,etc) setting in C#. But i am unable to do it. I am not sure how to do it. should i have to use WIN API like Openprinter , getprinter ,...
0
by: Chris | last post by:
Hi, I found this code to send print direct to printer. It works perfect. Imports System Imports System.Text Imports System.Runtime.InteropServices <StructLayout(LayoutKind.Sequential)> _...
5
by: moital | last post by:
I am trying to print directly to an HP printer using winspool.drv API. when I try English every thing works fine, when i try hebrew, I got garbge. any suggestions? code: public static extern...
5
by: Ken | last post by:
Hello All, I am hoping someone has used the windows GDI AddPrinter API. What I need to know is how the private static extern bool GetPrinter(IntPtr hPrinter, Int32 dwLevel, IntPtr pPrinter,...
0
by: Benoit Courchesne | last post by:
Hi, I'm trying to build my custom Printer Dialog box. The following code is supposed to Pop up the printer properties form and edit the PrinterSettings. My problem is that I'm able to show...
5
by: trint | last post by:
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...
6
by: trint | last post by:
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...
1
by: Paul M. | last post by:
Hi Everyone, I would like to use some of the Win32 printer functions in C# but they are in Winspool.lib. I was hoping that there is a way to do this without writing a dll in C++ and importing...
1
by: active | last post by:
Any idea why this fails with an OpenPrinter exited with code : 5 Message is: Access is denied. I have Adminstrative rights Public Structure PRINTER_DEFAULTS Dim pDatatype As Integer 'String ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.