inpout32.dll or inpoutx64.dll
The original version was written for use on NT based machines (NT, 2000, and XP), this allowed users direct access to the parallel port which could be either card or motherboard based as long as the address was below 0x7fff. A 32/64bit version was created by Phillip Gibbons which gave extra features and he has allowed access to his source code.

The address limitation will not allow the use of all parallel port cards on a Windows based PCs (32 or 64 bit), when the address assigned is greater than 0x7FFF. So I have modified the code and have compiled both 32/64 bit dlls. This will allow the continued use of the parallel port on any PC (Windows based) via add on cards.

Matlab. Note the method here only works on machines that also have a C compiler installed, for information about other methods can be found here

For 32 bit applications on either 32 or 64 bit Windows
For 64 bit applications on 64 bit Windows, change inpout32.dll to inpoutx64.dll in the library calls
For Matlab, required when calling a dll, this works for 32 and 64 bit
How to use
Change the dll name to the desired one, place the dll either in the correct system folder (dependant on whether a 32/64bit os and/or application is being used), in the application folder or in another folder. If the folder option is used, then the path needs to be included with the dll name i.e. path+"\input32.dll".
In the python example I had a problem on one PC where it failed to find the dll and had no option but to use the LoadLibrary command.
The port address for a read is 1 more than the write address i.e. if write address is 0378hex the read address is 0379hex.

Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As UShort) As Short
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As UShort,_
ByVal Value As UShort)

Private address As UShort = &H378
Private input As UShort
Private output As UShort	

Out(address, output)
input = Inp(address + 1)
<DllImport("inpout32.dll", CharSet:=CharSet.Auto, EntryPoint:="Inp32")>_ 
Private Shared Function Inp(ByVal PortAddress As UShort) As UShort
End Function

<DllImport("inpout32.dll", CharSet:=CharSet.Auto, EntryPoint:="Out32")>_
Private Shared Sub Out(ByVal PortAddress As Short, ByVal Data As UShort)
End Sub

Private port As UShort = &H378
Private input As UShort
Private output As UShort	

Out(port, output)
input = Inp(port+1)

from ctypes import windll

io = windll.inpout32
io = windll.LoadLibrary(path + '/inpout32.dll')

port = 0x378
io.Out32(port, output)
input = io.Inp32(port + 1)

private static extern void Out32(ushort PortAddress, ushort Data);
private static extern char Inp32(ushort PortAddress);

ushort port = 0x378;
ushort input;
ushort output =0;

input = Inp32(port + 1);
Out32(port, output);

if regexp(computer,'64') % setup 64bit options
   lib = 'inpoutx64.dll';
   libcall = 'inpoutx64';
else   % 32bit options
   lib = 'inpout32.dll';
   libcall = 'inpout32';
if ~libisloaded(libcall)

port_address = hex2dec('0378');

input = calllib(libcall, 'Inp32', port_address + 1); 
calllib(libcall, 'Out32', port_address, output) ;
unloadlibrary(libcall); %close library when finished

Content last updated: 15/09/2015
Written and Maintained by Gary Freegard