Solved

VB.Net Reading Parallel Port Under Windows XP/2000

Posted on 2003-12-07
8
31,974 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PL/SQL help needed. Script to compare columns and copy data between tables 6 64
mirrorEnds challenge 6 92
tripleUp challenge 7 73
Re-position sub-options beneath the TAB 7 74
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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 video teaches viewers about errors in exception handling.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

919 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

24 Experts available now in Live!

Get 1:1 Help Now