DLPort IO
DLPort IO
DLPort IO
2 User Manual
DriverLINX Port IO Driver wrapper
Copyright 1999 John Pappas (DiskDude). All rights reserved.
The latest version is always available from the Internet WWW: http://diskdude.cjb.net/
If you didn't download this package from the above URL, chances are it is out-of-date. Check often!
TDLPortIO Documentation
Page 2
IMPORTANT!
You should carefully read the license terms and conditions in Section 1.0 before using this
software. Your use of this software indicates your acceptance of the license agreement and
warranty.
Table of Contents
TDLPortIO Documentation
Page 3
1.1 FreeWare
You may use a FreeWare Copy of this Software for life. If you find it useful, an email to the author
telling him what you used it for would be nice, but not necessary. Your email address will not be
given to any other party, nor will it be sold or used for profit or commercial purposes.
See Section 6.0 for information on how to contact the author.
1.2 Distribution
You are hereby granted the right
to make as many copies of this software and its documentation as you wish;
give exact copies (including all files) of the original version to anyone;
distribute the software and documentation in its unmodified form via electronic means;
and distribute run-time files (TDLPortIO.dll, DLPortIOX.ocx, DLPortIO.bpl, DLPortIO.dpl) as
part of your application without any royalties.
TDLPortIO Documentation
Page 4
2.0 Introduction
2.1 What is the DriverLINX Port IO Driver?
The DriverLINX Port IO Driver allows you to use general port IO under Windows 95/98/NT. It
does this by using in and out assembler instructions under Windows 95/98 (a guess, since there is
no VxD), and through a kernel mode driver in Windows NT. It allows port read/writes of bytes, 16
and 32 bit words, as well as block read/writes of all ports from 100h to FFFFh.
The DriverLINX driver is provided freely, without support, by Scientific Software Tools (SST),
Inc. The author of TDLPortIO has no relation to SST, nor did he write the DriverLINX driver.
You can download the original DriverLINX driver package from the URLs below.
Included in this package is exactly what is distributed by SST, excluding the MSVC and Visual
BASIC demo code/examples which push the file to 1.5Mbytes (along with InstallShield), compared
to the 57kbytes for the DLL, kernel driver (.SYS) and API information included with this package
in the directory tree \DriverLINX.
Strictly speaking, it is not allowed to distribute the DriverLINX driver package other than as a
whole, but the original package is too big. I have nothing to gain by not providing the original
package and have provided ample opportunity for others to download it, from the URLs below. SST
probably require that their package be distributed as a whole so their work is recognised, perhaps
also why they request that their copyright messages are not to be removed. I believe that their work
has been acknowledged sufficiently in this package for there not to be a problem. No copyright
information has been removed from the DriverLINX driver files.
DriverLINX URL:
http://www.sstnet.com/ftp/unsupported/port95nt.exe
ftp://ftp.sstnet.com/pub/unsupported/port95nt.exe
My Backup URL:
http://diskdude.cjb.net/files/cbuilder/DLPortIO/port95nt.exe
TDLPortIO Documentation
Page 5
Burst read/write of a PortRec like array to include a mixture of Word and DWords
Block read/write of Word and DWord buffers
TDLPortIO is limited to what the DriverLINX driver provides, and hence cannot be 100%
compatible with TVicPort, as in the following example:
Hard/Soft access is not available, although the hardaccess property is present for code written for
TVicPort it simply have no effect. I assume DriverLINX uses the hard access by default, which
cannot be changed. That is, it does not ask the operating system politely before accessing a port, to
avoid collisions with some other driver/program. This is generally not a problem though, and would
execute faster since it isn't always requesting permission from the operating system.
The only other way TDLPortIO does not function the same as TVicPort is in the LPTBasePort and
LPTNumPorts properties. See Section 4.1.4 for more information.
TDLPortIO Documentation
Page 6
TDLPortIO Documentation
Page 7
TDLPortIO Documentation
Page 8
C:\WINDOWS\SYSTEM
C:\WINNT\SYSTEM32
(for Win95)
(for WinNT)
You aren't required to place the DLL here, but it's a good idea to do so. It will work so long as it
appears in the same directory as the program using it, or somewhere in your path.
To use the DLL in some directory not in your path, use the DLLPath property. The default is a null
string, meaning it will search the program's path, then the windows directory and your computer's
path.
\DriverLINX\drivers\DLPortIO.sys
This is the DriverLINX kernel mode driver which provides Port I/O in WinNT, and as such is only
required if you are running Windows NT.
You would normally place it in your Windows drivers directory, however the TDLPortIO
component can locate it elsewhere through the DriverPath property, but only if running it under an
administrator account (i.e. only if TDLPortIO will be installing, starting, stopping and removing the
driver during execution).
e.g. C:\WINNT\SYSTEM32\DRIVERS
If you are only going to run TDLPortIO under accounts in Windows NT which dont have
administrator access, you must install the driver into the system in addition to copying it to the
directory outlined above. See the directory \install\source for some example C code of installing the
driver into the Windows NT Service Control Manager.
Under administrator accounts, this is done automatically upon calling OpenDriver in the
component. Removal of the driver, if installed by OpenDriver, occurs when calling CloseDriver in
administrator accounts. This was done to simulate the behaviour of TVicPort; although TVicPort
(shareware version) only works under administrator accounts.
Note that TDLPortIO will not remove a driver in CloseDriver that was previously installed before
TDLPortIO was started; nor will it stop a driver which was running previously. In other words,
when you call CloseDriver, it will return the status of the driver to what it was before OpenDriver
was called. CloseDriver is automatically called when the component is destroyed, if OpenDriver
was called previously.
TDLPortIO Documentation
Page 9
TDLPortIO Documentation
Page 10
TDLPortIO Documentation
Page 11
Opens the DriverLINX DLL. If running under Windows NT, it will start the kernel mode
driver, and if the driver isnt installed, it will attempt to install it into the system.
[procedure] CloseDriver()
Closes the DriverLINX DLL. If running under Windows NT, it will stop the kernel mode
driver (if started in OpenDriver), and remove it if it was installed in OpenDriver.
[procedure] PortControl(TPortRec, NumberOfPorts)
Similar to the PortControl method provided by TVicPort, it will take an array of TPortRec
structs/records, the number given by NumPorts, and read/write data as requested.
This is not available in the ActiveX version.
[procedure] PortCommand(TPortCommand, NumberOfPorts)
TDLPortIO Documentation
Page 12
Read/Write
Read/Write
Read/Write
Read/Write
Set this for the path to the DriverLINX dlportio.sys driver file when running under Windows
NT in administrator mode, and the driver hasnt been installed previously. i.e. when the
wrapper installs the driver, it will use this as the path to the dlportio.sys file.
Do not specify the filename in this property, nor any trailing \ character.
[String] DLLPath
Read/Write
Set this for the path to the DriverLINX dlportio.dll DLL file. If you set it to the null string, it
will search the path of the program .EXE, then the Windows directory and other directories
in your path.
Do not specify the filename in this property, nor any trailing \ character.
[Boolean] ActiveHW
Read Only
Read this to see if the DriverLINX driver is active. After a call to OpenDriver, it will read
true if no errors occurred, otherwise it will be false and you can use the LastError property
to see what happened where.
[Boolean] HardAccess
Read/Write
This property has no effect, and is here to maintain compatibility with TVicPort.
[String] LastError
Read Only
If an error occurred in OpenDriver or CloseDriver, and the ActiveHW property did not
change state, this string will indicate the error which occurred.
TDLPortIO Documentation
Page 13
Read/Write
When read, it returns the boolean state of the pin specified. When written, it will set that pin
high (5V) or low (0V), depending on the boolean value given.
Note that a high voltage on the pin corresponds to a boolean true, whereas a low voltage
corresponds to a boolean false. i.e. any inversions that the printer port does on signals is also
done in software to counteract the effect.
The index range is only valid in the range 1-25. Invalid indexes are ignored.
This property is only available as function calls in the ActiveX version:
[Boolean function] GetPin(PinNumber)
[procedure]
SetPin(PinNumber, State)
[Boolean] LPTAckwl
Read Only
Read Only
TDLPortIO Documentation
[Boolean] LPTPaperEnd
Page 14
Read Only
Read Only
Read Only
Read Only
Returns the number of printer ports installed into the Windows system via the Control Panel.
This information is obtained by reading the Windows registry.
[Byte] LPTNumber
Read/Write
Selects the printer port for use with all the methods and properties above. Ports are identified
by their number (i.e. 1, 2, 3, etc), not by their port address.
Note that port numbers are those assigned by Windows in the Control Panel.
[Word] LPTBasePort
Read Only
Returns the base address of the current printer port being operated on.
Similarly to the LPTNumPorts property, this information is obtained from the Windows
registry.
4.2 As a DLL
The DLL version implements all the methods and properties mentioned for both TDLPortIO and
TDLPrinterPortIO above. Properties which are Read/Write are split into two functions, GetXXX,
and SetXXX which return the current value (read) of the property, and write a new value of the
property respectively, where XXX is the property name.
All functions use the standard Windows stdcall calling convention.
TDLPortIO Documentation
Page 15
5.2 To Do List
The TDLPortIO package has had many improvements since the first version in January 1999. It
does everything I originally wanted it to do, and much much more. I only wanted a simple wrapper
for C++ Builder for a small project I was working on. I had never imagined to write the Delphi,
ActiveX and DLL versions too! It got to a point where I stopped working on my other project, and
started working on TDLPortIO alone
It is envisaged that no further improvements will be made to the TDLPortIO package, except
perhaps fixes to any bugs that people may discover.
TDLPortIO Documentation
Page 16
All indexed properties in the ActiveX control, when used, would result in Access
Violations. To avoid this, they have been converted into methods. I don't know how to
create ActiveX control indexed properties using C++ Builder. If someone can help, it would
be appreciated.
The C++ code now looks a little cleaner, and faster as some small functions in the
TDLPrinterPortIO component have been put inline.
Fixed a bug in the installation program where it would report an error when the DriverLINX
driver was already installed into the Windows NT Service Control Manager.
Added a program to install the DriverLINX driver on a Windows NT system (so users
without administrator privileges can use TDLPortIO). It will make the driver active at
bootup, the only way non-administrator accounts can use the driver. Do not use this program
if you will only run TDLPortIO under an account with administrator privileges.
TDLPortIO Documentation
Page 17
Fixed a bug in LPTAutofd(bool) where it would always set the Auto LF state of the printer
to false, not to what it was told to set it to.
All inverted pins on the printer port are now inverted in software also, for the Pin[] property
only. This means if you set any of the pins to true, and it is an output pin, it means the pin
will be at 5V. Setting a pin to false will lower the pin to 0V.
This was done to further maintain compatibility with TVicPort.
Disabled Pin[] writes on pins 10,11,12,13,15 since these are the control line inputs, and to
again maintain compatibility with TVicPort.
You no longer have to have the DriverLINX driver installed into Windows NT before you
can use the wrapper. It is installed and started automatically when you call OpenDriver(),
and stopped and removed automatically when you call CloseDriver() or if you don't call it
directly, it will be called for you in the destructor.
Under Windows 95/98, as before, the DLL isn't loaded until you call OpenDriver() and is
unloaded when you call CloseDriver().
TDLPortIO Documentation
Page 18
TDLPortIO Documentation
Page 19
7.0 Thanks!
A big thanks to Peter <[email protected]> for his testing of the DriverLINX driver and this
wrapper in his copy of Windows NT. Since I don't run NT myself, I would have not been able to
debug the automatic driver loading/unloading code without his help, and prototype board! (:
Another big thanks to Peter Holm <[email protected]> for his printer port detection
algorithm and code.
8.0 Trademarks
DriverLINX is a registered trademark of Scientific Software Tools, Inc.
Microsoft, Windows, Win95, Win98, WinNT, and Visual BASIC are registered trademarks of
Microsoft Corp.
C++ Builder, and Delphi are registered trademarks of Inprise Corp.