# Ned HELP about Parallel Port Interfacing ....

Status
Not open for further replies.

#### AEL

##### Newbie level 4
Elo, thanx .. I already have a program in "c++" that can directly write a byte or word into parallel port ... however When i used "Borland C++ Builder 6" the output command is not supported in "Borland C++ Builder 6" ..... do you know how to interfacing i only want to write a byte directly into the paralle port .... using "Borland C++ Builder 6" and an O.S Windows XP !!! Hope u will HELP me ....

#### metal

##### Full Member level 6
Hi

You can use IO.DLL, Inpout.dll, or any dll that uses the PC drivers indirectly to access the LPT. I think that IO.DLL is the best here.

#### AEL

##### Newbie level 4
I have many IO.dll but there are very dificult to understand ... and also there are errors with it especially the unresolved external errors ... do you have the best DLL that can be easily understood and functional ... well i try these link **broken link removed** but its dificult sob ....help

I have many IO.dll but there are very dificult to understand ... and also there are errors with it especially the unresolved external errors ... do you have the best DLL that can be easily understood and functional ... well i try these link **broken link removed** the TVicPort but its dificult sob ....help

#### metal

##### Full Member level 6
Hi

Go to www.geekhideout.com/iodll.shtml and download IO.DLL, it worked for me using both VB6 and C++, I just wanted to see if it really works or not, and it did.

C/C++ Prototypes
void WINAPI PortOut(short int Port, char Data);
void WINAPI PortWordOut(short int Port, short int Data);
void WINAPI PortDWordOut(short int Port, int Data);
char WINAPI PortIn(short int Port);
short int WINAPI PortWordIn(short int Port);
int WINAPI PortDWordIn(short int Port);
void WINAPI SetPortBit(short int Port, char Bit);
void WINAPI ClrPortBit(short int Port, char Bit);
void WINAPI NotPortBit(short int Port, char Bit);
short int WINAPI GetPortBit(short int Port, char Bit);
short int WINAPI RightPortShift(short int Port, short int Val);
short int WINAPI LeftPortShift(short int Port, short int Val);
short int WINAPI IsDriverInstalled();

To use IO.DLL with Visual C++/ Borland C++, etc, you'll need to use LoadLibrary and GetProcAddress. Yes, it's more of a pain than using a .lib file, but because of name mangling, it's the only reliable way of calling the functions in IO.DLL. I've gone ahead and done the dirty work for you:

Just save these two files and include them in your project. For a Visual C++, you may need to add #include "StdAfx.h" at the top of io.cpp otherwise the compiler will whine at you.

These two files take care of calling LoadLibrary and all the neccessary calls to GetProcAddress, making your life happy once again.

The only step you are required to do is call LoadIODLL somewhere at the beginning of your program. Make sure you do this or you will find yourself faced with all sorts of interesting crashes.

Good Luck

#### AEL

##### Newbie level 4
Elo

Can you give me a simple code in borland c++ builder 6 ..... just setting the palallel port into 0x01. Is this correct OutPort(0x378,1); Thanx Again .....

#### metal

##### Full Member level 6
Hi

I never used borland C++

But I can suggest you download DLPortIO, when installed, you will find two examples in its folder, one for VB, and the other for MVC++, I was working with both of them this morning in order to test the functionality, and I find them a very good starting point for both VB and C++ lovers.

Good luck

#### echo47

A WinNT/2k/XP application cannot write directly to an I/O port unless you first install a kernel mode device driver that performs the I/O, or tweaks a Windows access control bit somewhere that gives you access.

I like PortTalk. It includes an easy-to-use program called allowio that you run from the command line. It auto-installs a driver, and then gives any application temporary access to selected I/O ports. Your ordinary in/out opcodes will work.

Lots of info at "Parallel Port Central", including a link to PortTalk:

I don't know much about Borland's compiler, but someone said it doesn't include anything like inp() or outp(), and then suggested these little functions. I haven't tried them myself:

Code:
int inp(int port)
{
__asm  mov  dx,[port]
__asm  in   al,dx
return _AX;
}

void outp(int port, unsigned char data)
{
__asm  mov  dx,[port]
__asm  mov  al,[data]
__asm  out  dx,al
}
Those should work if you use them in a program that you've launched with allowio.

Status
Not open for further replies.