473,399 Members | 2,858 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,399 software developers and data experts.

Doing I/O to the Printer port and legacy IO space in C# ?

What is the way to send/read bits to the printer port at the hex 3F8-3FF or
any other legacy io space??

Does C# include the methods to drive the printer or other ports?

tia
Nov 16 '05 #1
6 1885
Bradley1234,

AFAIK, there is nothing in .NET to access it. You might have to
actually use CreateFileEx and pass LPT1 (assuming your printer is connected
to that) in order to write to the printer port (there might also be a more
elegant way, but I am not sure).

However, you will most likely have to access the API in order to
read/write bits directly to the printer attached to a port.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Bradley1234" <so*****@yahoo.com> wrote in message
news:fcJtd.2513$N%6.101@trnddc05...
What is the way to send/read bits to the printer port at the hex 3F8-3FF
or
any other legacy io space??

Does C# include the methods to drive the printer or other ports?

tia

Nov 16 '05 #2
Thanks Nicholas,

I found one site so far, http://www.codeproject.com/csharp/csppleds.asp
that claims a way to do this with their .dll (Im unable to copy text from
the site) but when I entered their code verbatim? Errors,

using System.Runtime.InteropServices;

.... windows generated form1 + declarations

public class portAccess

{
[DllImport{"inpout32.dll", EntryPoint="Out32")]

* *

// syntax error, "]" expected and "{" is invalid token, "=" invalid
token
public static extern void Output(int adress, int value);

}

There is no help available for "DllImport" or its syntax that I could find

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Bradley1234,

AFAIK, there is nothing in .NET to access it. You might have to
actually use CreateFileEx and pass LPT1 (assuming your printer is connected to that) in order to write to the printer port (there might also be a more
elegant way, but I am not sure).

However, you will most likely have to access the API in order to
read/write bits directly to the printer attached to a port.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Bradley1234" <so*****@yahoo.com> wrote in message
news:fcJtd.2513$N%6.101@trnddc05...
What is the way to send/read bits to the printer port at the hex 3F8-3FF
or
any other legacy io space??

Does C# include the methods to drive the printer or other ports?

tia


Nov 16 '05 #3
Bradley1234,

The declaration should be:

[DllImport("inpout32.dll", EntryPoint="Out32")]

Not:

[DllImport{"inpout32.dll", EntryPoint="Out32")]

Notice the bracket instead of the open parenthesis.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Bradley1234" <so*****@yahoo.com> wrote in message
news:REJtd.639$Qp.189@trnddc01...
Thanks Nicholas,

I found one site so far, http://www.codeproject.com/csharp/csppleds.asp
that claims a way to do this with their .dll (Im unable to copy text
from
the site) but when I entered their code verbatim? Errors,

using System.Runtime.InteropServices;

... windows generated form1 + declarations

public class portAccess

{
[DllImport{"inpout32.dll", EntryPoint="Out32")]

* *

// syntax error, "]" expected and "{" is invalid token, "=" invalid
token
public static extern void Output(int adress, int value);

}

There is no help available for "DllImport" or its syntax that I could find

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Bradley1234,

AFAIK, there is nothing in .NET to access it. You might have to
actually use CreateFileEx and pass LPT1 (assuming your printer is

connected
to that) in order to write to the printer port (there might also be a
more
elegant way, but I am not sure).

However, you will most likely have to access the API in order to
read/write bits directly to the printer attached to a port.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Bradley1234" <so*****@yahoo.com> wrote in message
news:fcJtd.2513$N%6.101@trnddc05...
> What is the way to send/read bits to the printer port at the hex
> 3F8-3FF
> or
> any other legacy io space??
>
> Does C# include the methods to drive the printer or other ports?
>
> tia
>
>



Nov 16 '05 #4
Hey thanks, that works so much better!

But... it cannot or will not add inpout32.dll

It cannot be added because its not a valid assembly... Okay I need to
compile it somehow? or run it by something in the command line?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2******************@TK2MSFTNGP12.phx.gbl...
Bradley1234,

The declaration should be:

[DllImport("inpout32.dll", EntryPoint="Out32")]

Not:

[DllImport{"inpout32.dll", EntryPoint="Out32")]

Notice the bracket instead of the open parenthesis.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Bradley1234" <so*****@yahoo.com> wrote in message
news:REJtd.639$Qp.189@trnddc01...
Thanks Nicholas,

I found one site so far, http://www.codeproject.com/csharp/csppleds.asp
that claims a way to do this with their .dll (Im unable to copy text
from
the site) but when I entered their code verbatim? Errors,

using System.Runtime.InteropServices;

... windows generated form1 + declarations

public class portAccess

{
[DllImport{"inpout32.dll", EntryPoint="Out32")]

* *

// syntax error, "]" expected and "{" is invalid token, "=" invalid
token
public static extern void Output(int adress, int value);

}

There is no help available for "DllImport" or its syntax that I could find
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Bradley1234,

AFAIK, there is nothing in .NET to access it. You might have to
actually use CreateFileEx and pass LPT1 (assuming your printer is

connected
to that) in order to write to the printer port (there might also be a
more
elegant way, but I am not sure).

However, you will most likely have to access the API in order to
read/write bits directly to the printer attached to a port.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Bradley1234" <so*****@yahoo.com> wrote in message
news:fcJtd.2513$N%6.101@trnddc05...
> What is the way to send/read bits to the printer port at the hex
> 3F8-3FF
> or
> any other legacy io space??
>
> Does C# include the methods to drive the printer or other ports?
>
> tia
>
>



Nov 16 '05 #5
Bradley,

It's not a managed assembly, so you don't add it to the references for
your project. Rather, you have to make sure it is located where LoadLibrary
can find it (try in the directory the executable runs from, etc, etc).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bradley1234" <so*****@yahoo.com> wrote in message
news:feKtd.644$Qp.308@trnddc01...
Hey thanks, that works so much better!

But... it cannot or will not add inpout32.dll

It cannot be added because its not a valid assembly... Okay I need to
compile it somehow? or run it by something in the command line?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2******************@TK2MSFTNGP12.phx.gbl...
Bradley1234,

The declaration should be:

[DllImport("inpout32.dll", EntryPoint="Out32")]

Not:

[DllImport{"inpout32.dll", EntryPoint="Out32")]

Notice the bracket instead of the open parenthesis.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Bradley1234" <so*****@yahoo.com> wrote in message
news:REJtd.639$Qp.189@trnddc01...
> Thanks Nicholas,
>
> I found one site so far, http://www.codeproject.com/csharp/csppleds.asp
> that claims a way to do this with their .dll (Im unable to copy text
> from
> the site) but when I entered their code verbatim? Errors,
>
> using System.Runtime.InteropServices;
>
> ... windows generated form1 + declarations
>
> public class portAccess
>
> {
>
>
> [DllImport{"inpout32.dll", EntryPoint="Out32")]
>
> * *
>
> // syntax error, "]" expected and "{" is invalid token, "=" invalid
> token
>
>
> public static extern void Output(int adress, int value);
>
> }
>
>
>
> There is no help available for "DllImport" or its syntax that I could find >
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:%2****************@TK2MSFTNGP12.phx.gbl...
>> Bradley1234,
>>
>> AFAIK, there is nothing in .NET to access it. You might have to
>> actually use CreateFileEx and pass LPT1 (assuming your printer is
> connected
>> to that) in order to write to the printer port (there might also be a
>> more
>> elegant way, but I am not sure).
>>
>> However, you will most likely have to access the API in order to
>> read/write bits directly to the printer attached to a port.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>>
>> "Bradley1234" <so*****@yahoo.com> wrote in message
>> news:fcJtd.2513$N%6.101@trnddc05...
>> > What is the way to send/read bits to the printer port at the hex
>> > 3F8-3FF
>> > or
>> > any other legacy io space??
>> >
>> > Does C# include the methods to drive the printer or other ports?
>> >
>> > tia
>> >
>> >
>>
>>
>
>



Nov 16 '05 #6
Hey getting closer, it runs with no complaints. I finally pasted the .dll
file in about 10 different folders, where the project is located, the debug,
bin, obj, every folder. and it found the one it wanted.

I like the built in exception handler with this C#, nice improvement.

At least its appearing to run, now I can leave for a bit, will try more
later, thanks for your help
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eB**************@TK2MSFTNGP10.phx.gbl...
Bradley,

It's not a managed assembly, so you don't add it to the references for
your project. Rather, you have to make sure it is located where LoadLibrary can find it (try in the directory the executable runs from, etc, etc).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bradley1234" <so*****@yahoo.com> wrote in message
news:feKtd.644$Qp.308@trnddc01...
Hey thanks, that works so much better!

But... it cannot or will not add inpout32.dll

It cannot be added because its not a valid assembly... Okay I need to
compile it somehow? or run it by something in the command line?
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:%2******************@TK2MSFTNGP12.phx.gbl...
Bradley1234,

The declaration should be:

[DllImport("inpout32.dll", EntryPoint="Out32")]

Not:

[DllImport{"inpout32.dll", EntryPoint="Out32")]

Notice the bracket instead of the open parenthesis.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Bradley1234" <so*****@yahoo.com> wrote in message
news:REJtd.639$Qp.189@trnddc01...
> Thanks Nicholas,
>
> I found one site so far, http://www.codeproject.com/csharp/csppleds.asp > that claims a way to do this with their .dll (Im unable to copy text > from
> the site) but when I entered their code verbatim? Errors,
>
> using System.Runtime.InteropServices;
>
> ... windows generated form1 + declarations
>
> public class portAccess
>
> {
>
>
> [DllImport{"inpout32.dll", EntryPoint="Out32")]
>
> * *
>
> // syntax error, "]" expected and "{" is invalid token, "=" invalid > token
>
>
> public static extern void Output(int adress, int value);
>
> }
>
>
>
> There is no help available for "DllImport" or its syntax that I could

find
>
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
> wrote
> in
> message news:%2****************@TK2MSFTNGP12.phx.gbl...
>> Bradley1234,
>>
>> AFAIK, there is nothing in .NET to access it. You might have to
>> actually use CreateFileEx and pass LPT1 (assuming your printer is
> connected
>> to that) in order to write to the printer port (there might also be a >> more
>> elegant way, but I am not sure).
>>
>> However, you will most likely have to access the API in order to
>> read/write bits directly to the printer attached to a port.
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mv*@spam.guard.caspershouse.com
>>
>>
>> "Bradley1234" <so*****@yahoo.com> wrote in message
>> news:fcJtd.2513$N%6.101@trnddc05...
>> > What is the way to send/read bits to the printer port at the hex
>> > 3F8-3FF
>> > or
>> > any other legacy io space??
>> >
>> > Does C# include the methods to drive the printer or other ports?
>> >
>> > tia
>> >
>> >
>>
>>
>
>



Nov 16 '05 #7

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

Similar topics

4
by: Lizard King | last post by:
Hi. I have a computer running a third party software (POS). The thing is this application opens the printer port and I need to use another program while the first one is still running. Since...
1
by: Bruce Wood | last post by:
I'm having a devil of a time calling DeviceCapabilities() in order to get the list of paper names / codes / sizes for a printer. Here is my code and the input it produces: static extern Int32...
1
by: Patriicia | last post by:
A legacy application (I don't have the source code for the application) transmits reports to a printer. One of the reports that are sent to the printer needs to be inserted into a database. With...
4
by: joe bloggs | last post by:
I am writing a mobile application to interface with a legacy system and I am planning to use web services to communicate with this system. The legacy system receives data through a serial port. ...
4
by: Paul H | last post by:
OK, I tried getting and old Newbury Data ND2500 working using the "Generic /Text only" driver in Win XP. It prints, but I could not find a way to set a custom page size that matches the paper I am...
1
by: hasanainf | last post by:
Hi all and thanking you all in advance for your help My client wants to use a receipt printer. Since I have never used one before I have some questions. 1. Unlike other printers which are set...
4
ADezii
by: ADezii | last post by:
Recently, there seems to be several questions specifically related to Printers and changing Printing characteristics for Forms and Reports. For this reason alone, I decided to dedicate this week's...
0
by: =?Utf-8?B?Q2hhcmxpZQ==?= | last post by:
Hi, This apparently is a common problem and I've yet to read a solution that actually works for my specific situation. I have a Zebra RW220 printer that I connect to via Bluetooth connection...
0
by: praveenhathwar | last post by:
Im trying to print to a 40 column printer through my VB Application. But the printer instead of printing it will keep showing Spooling status. Im Using Epson TM-U220PD Printer, VB 6.0 and Sql Server...
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
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
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...
0
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,...
0
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...

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.