473,657 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Rea dPrinter(
lhPrinter,st1,s t1.Length,ref pcRead) ))
{
listBox2.Items. Add(st1);
}

public class PrintDirect: Form1
{
[ DllImport( "winspool.drv", CharSet=CharSet .Ansi,ExactSpel ling=true,
CallingConventi on=CallingConve ntion.StdCall)]
public static extern bool ReadPrinter(Int Ptr hPrinter,string data,
int buf,ref int pcRead);

Am I even close?
Thanks,
Trint

Nov 16 '05 #1
5 7045
>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***********@g mail.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***********@g mail.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******** ******@TK2MSFTN GP09.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***********@g mail.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
4731
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 , setprinter . I did try with PrinterSetting.setHDevMode but it does not work. Its their is a simple way to change printersetting. thanks umesh.
0
2352
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)> _ Public Structure DOCINFO<MarshalAs(UnmanagedType.LPWStr)> Public pDocName As String<MarshalAs(UnmanagedType.LPWStr)>
5
8673
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 long WritePrinter(IntPtr hPrinter,string data, int buf,ref int pcWritten); string PCL5Commands = "<esc>(15H<esc>(s0p12.00h10.1h0s0b4102T <hebrew
5
9102
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, Int32 dwBuf, out Int32 dwNeeded);
0
2577
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 the Printer Properties form but I'm unable to write back the settings to my PrinterSettings It either crash with a null reference exception or my application freeze completly.
5
3677
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 I can make this work (and any help is appreciated): string reaDstrinG = ""; int pcRead = 0; for (int i = 0; i < 23; i++) { PrintDirect.ReadPrinter(lhPrinter,reaDstrinG,100,ref pcRead);
6
7480
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 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++)
1
4878
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 the functions. So, is there a way? Paul M.
1
8347
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 I"VE TRIED BOTH Dim pDevMode As Integer Dim DesiredAccess As Integer
0
8325
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8621
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.