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

  • Thread starter Thread starter Bradley1234
  • Start date Start date
B

Bradley1234

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
 
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.
 
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 said:
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]
- (e-mail address removed)


Bradley1234 said:
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
 
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]
- (e-mail address removed)


Bradley1234 said:
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



in
message news:%[email protected]...
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]
- (e-mail address removed)


Bradley1234 said:
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
 
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 said:
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]
- (e-mail address removed)


Bradley1234 said:
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



in
message news:%[email protected]...
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]
- (e-mail address removed)


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
 
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]
- (e-mail address removed)

Bradley1234 said:
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?


in
message news:%23X%[email protected]...
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]
- (e-mail address removed)


Bradley1234 said:
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]" <[email protected]>
wrote
in
message 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]
- (e-mail address removed)


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
 
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 said:
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]
- (e-mail address removed)

Bradley1234 said:
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?


in
message news:%23X%[email protected]...
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]
- (e-mail address removed)


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]" <[email protected]>
wrote
in
message 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]
- (e-mail address removed)


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
 
Back
Top