Direct I/O Access from Win32 User Mode Applications to PC Parallel Port(s) under Microsoft Windows NT 4.0 |
| Overview | The
Parallel Port Direct I/O Access package delivers the ability to access
PC parallel ports from Win32 applications under Microsoft Windows NT 4.0.
Previously, the only way would have been to write an NT device driver to
perform the I/O on behalf of the application.
This kernel mode driver and Win32 library combination allow Win32 applications to execute IN and OUT instructions to the parallel port device hardware I/O ports. Access is coordinated with the standard NT parallel driver to ensure that the parallel port is only 'claimed' if no other process is currently using it. Once the port is 'claimed', other processes are blocked from using the port (assuming they also use the standard parallel port arbitration scheme). Once the application has finished using the parallel port, it may either exit or call the 'release' API and the parallel port is free for use by any other process again. Do you have a DOS/Windows 16bit or Windows 95/98 32bit application that accesses a Parallel Port that you want to run under NT and you don't have the source? Now, with one simple command, you can grant Parallel Port access to a specific application. The program RUNAPP.EXE comes with the Direct I/O Access package and can be run to allow another application the Parallel Port. To run a 32bit app use this command: To run a 16bit app use this command:
|
|||||||||||||||||||||||
| How it works | Normally,
under Windows NT, access is not permitted to the I/O port range of the
parallel port (and most others). Executing an IN or OUT instruction causes
a privileged instruction exception resulting in termination of the process.
The driver works by changing the I/O permission map (IOPM) for the process that 'claims' the indicated parallel port. Changing the IOPM, allows the process free access to the I/O port range of the parallel port hardware. It also supports additional parallel ports added using expansion cards.
|
|||||||||||||||||||||||
| The Details | The
API calls are provided in a Win32 DLL. One call is all that is required
to use the direct I/O functionality. The Win32 application is linked with
the supplied import library and the kernel driver is demand loaded as necessary.
No tampering with the registry or rebooting is needed.
The API calls are documented here: Include the header file for definitions and function prototypes. #include "ParllIo.h" The GetParallelPortCount API returns the number of parallel ports present in the PC. INT WINAPI GetParallelPortCount(VOID) Return value:
BOOL WINAPI GetParallelPortInfo(
Arguments:
// size of structure DWORD dwParllIoInfoSize; // address of parallel port DWORD dwPortAddress; // span of parallel port DWORD dwPortSpan; } PARLLIOINFO, *PPARLLIOINFO; The ClaimParallelPort API attempts to allocate the specified parallel port from the standard Windows NT parallel driver. A timeout may be specified to wait for the port to become free if already allocated. Additionally, either no wait may be specified or wait indefinitely. BOOL WINAPI ClaimParallelPort(
Arguments:
BOOL WINAPI ReleaseParallelPort(
Arguments:
INT WINAPI OutByte(
INT WINAPI OutWord(
INT WINAPI OutDWord(
INT WINAPI InByte(
INT WINAPI InWord(
INT WINAPI InDWord(
|
|||||||||||||||||||||||
| I/O Timing | I/O instructions executing
in user mode (ring 3) will take longer than executing in kernel mode (ring
0). It is however, dependant upon the processor, but the number of clocks
taken is generally two to three times that of comparable real-mode (i.e.
MS-DOS) execution. Having said that, it is significantly quicker than calling
down to a kernel mode driver for each IN / OUT instruction as some other
NT I/O drivers require.
|
|||||||||||||||||||||||
| Installation | The Direct I/O Access developer
package consists of a header file ParllIo.h
containing definitions and function prototypes, a Microsoft Visual C++
5.0 compatible import library ParllIo.lib
to be linked with the application and some example test programs. Both
C and Visual Basic examples are supplied.
The Direct I/O Access runtime package consists of two files, a kernel mode driver ParllIo.sys and a dynamic link library, ParllIo.dll. These files should be distributed with the application. The driver may either be loaded on-demand or may be loaded when the system boots. If the driver is loaded on-demand, the user running the application must have NT administrator rights. If it is envisiged that the user running the program will not have NT administrator rights, the driver can be installed to load at boot. NT administrator rights are still needed during setup, but once completed the driver can be used by non administrative users. A setup program is provided to create the necessary registry entries to load the driver at boot. It can be run in quiet mode so that it can be called from the application setup program or in interactive mode. If the driver will be loaded on-demand, the application setup program can copy the files into the application directory. Running the command setup /h show the setup program options. ![]() To perform a quiet mode installation from another setup program, run the following command setup c:\winnt /q.This will copy ParllIo.sys to the system32\drivers directory and ParllIo.dll to the system32 directory and make the necessary registry entries to load the driver on boot. Alternatively, use the setup program in interactive mode as shown below.
|
|||||||||||||||||||||||
| Windows 95/98 Support | Under Microsoft
Windows 95/98 direct port I/O is allowed to certain I/O address ranges.
The parallel ports are one such range. When running under Windows 95/98,
the library ParllIo.dll
skips the calls to the kernel driver allowing the same code base and file
set to be shipped for both Windows NT and Windows 95/98.
Note: A Windows 95/98 driver allowing coordinated access to parallel ports may be released if there is sufficient demand.
|
|||||||||||||||||||||||
| Price and Availability |
|
|||||||||||||||||||||||
| License Agreements | Click
here to read the development license agreement.
Click here to read the run-time license agreement. |
You must send me your E-Mail address with the order, as
this is the only method of distribution of this product
