Solved

VB.Net Reading Parallel Port Under Windows XP/2000

Posted on 2003-12-07
8
31,962 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now