Solved

VB.Net Reading Parallel Port Under Windows XP/2000

Posted on 2003-12-07
8
32,029 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

626 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