Solved

VB.Net Reading Parallel Port Under Windows XP/2000

Posted on 2003-12-07
8
31,989 Views
Last Modified: 2011-08-18
I want to write an application in VB.Net that will allow me to read data from a parallel printer port.

1. How can I do this to specifically work under Windows XP? How do I program this in VB.Net to read data?

2. Is there a way to do this that will work platform independent - i.e. any platform that will work with my VB.Net program will be able to use my program to read from the parallel port.
0
Comment
Question by:mswat
8 Comments
 
LVL 3

Expert Comment

by:rkosai
ID: 9893886
It is not possible to access the parallel port directly under Windows 2000 or XP.  Under the 9x codebase, you are able to read and write from LPT1 at the memory address 0x378 using the inportb() and outportb() functions in C++.  However, because of the "protected" memory of the NT code base it is impossible to access the parallel port under 2k or XP without using a driver.  You can download several free parallel port drivers; I have listed a few links below.

http://www.paraport.net/
http://www.internals.com/ (click on the WinIO link)

You may also want to check out Jan Axelson's Parallel Port Complete from your library, as (I think, can't remember for sure) it has some good information on accessing the parallel port from VB.
0
 
LVL 1

Expert Comment

by:RocketMan801
ID: 9900714
an free and easy driver is here to download:
http://www.geekhideout.com/iodll.shtml

io.dll

theres a txt file with help about the driver, it reaally easy to use (1 code line to read)
0
 

Author Comment

by:mswat
ID: 9902546
Whenever I try to add a reference to these dll's under VB.NET (DOT NET) I get an error saying that the file is not a valid assembly and is not supported. Is there a way around this or is the dll not supported by VB.NET?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 3

Accepted Solution

by:
rkosai earned 63 total points
ID: 9902976
You may need to use the older VB method of using libraries:

The website suggested by Rocketman801 includes these Visual Basic Prototypes:
Private Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Byte)
Private Declare Sub PortWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Integer)
Private Declare Sub PortDWordOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data As Long)
Private Declare Function PortIn Lib "IO.DLL" (ByVal Port As Integer) As Byte
Private Declare Function PortWordIn Lib "IO.DLL" (ByVal Port As Integer) As Integer
Private Declare Function PortDWordIn Lib "IO.DLL" (ByVal Port As Integer) As Long
Private Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Private Declare Sub ClrPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Private Declare Sub NotPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
Private Declare Function GetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte) As Boolean
Private Declare Function RightPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Private Declare Function LeftPortShift Lib "IO.DLL" (ByVal Port As Integer, ByVal Val As Boolean) As Boolean
Private Declare Function IsDriverInstalled Lib "IO.DLL" As Boolean

You can add these into a module, and reference them as functions in your code.
0
 
LVL 1

Assisted Solution

by:RocketMan801
RocketMan801 earned 62 total points
ID: 9908248
1º first copy io.dll in the bin folder where are the compiled binaries of your application

2º declare a function from the io.dll, for example
Private Declare Sub SetPortBit Lib "IO.DLL" (ByVal Port As Integer, ByVal Bit As Byte)
(not necesarily in a module)

3º use the function, for example:
Call SetPortBit(&H378, Val(Text1.Text))

4º thats all dude!
0
 
LVL 1

Expert Comment

by:games0802
ID: 10979179
Even though this question is closed, I thought I would put my 2 cents in.

I'm developing a C# program where I needed to manipulate the parallel port.  I used a program written in C to access it called PortTalk.  The process to create a dll which is easily called from C# or VB.NET was painless.  I use inport(ushort addr) and outport(ushort addr, byte val) to read and write the addresses.  You may email me at games0802 At hotmail Dot com for more info.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tripleUp challenge 7 79
My project did see openJDK that I installed. What could be the problem 7 143
mapBully challenge 6 135
Re-position the objects 7 110
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question