Board index » delphi » accessing parallel port through delphi

accessing parallel port through delphi

Does anybody know how to access the parallel ports in delphi, or some
library that can be used for this?

Hello everybody. For some reason I need to access the parallel ports of the
computer. I used to be able to access them through win95 and in a pentium
100 computer; but now I have to work with win98 and a p2. Assembly code used
to work in the past, but not anymore.

 

Re:accessing parallel port through delphi


Quote
Umut Topkara wrote:

> Does anybody know how to access the parallel ports in delphi, or some
> library that can be used for this?

> Hello everybody. For some reason I need to access the parallel ports of the
> computer. I used to be able to access them through win95 and in a pentium
> 100 computer; but now I have to work with win98 and a p2. Assembly code used
> to work in the past, but not anymore.

This is a violation of the protected mode. It is nonsense
that it worked on Win95, but it was permitted for "upgrade"
compatibility.

http://www.geocities.com/SiliconValley/2926/tpf.html
chapter "windows" has workarounds, in case you do not want
to make the clean solution, a device driver. Look for
TinyPort and other DLL solutions, also on the DSP etc.

Franz Glaser

Re:accessing parallel port through delphi


Use CreateFile to get a handle to it, and then use the usual file
accessing routines
e.g.
Var
    lName: Array[0..6] of Char;
    lHandle: THandle;
    lTest:String;
    lBytesWritten: Integer;
Begin
    StrPCopy(lName, 'COM1:');
    lHandle := CreateFile(lName, GENERIC_READ or GENERIC_WRITE,0,Nil,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
    lTest := 'Test';
    WriteFile (lHandle, lTest[1], Length(lTest), lBytesWritten, Nil) ;
    CloseHandle(lHanlde);
end;

Reading from the port can be done a similar way

HTH
Allan

Quote
>Does anybody know how to access the parallel ports in delphi, or some
>library that can be used for this?

>Hello everybody. For some reason I need to access the parallel ports of the
>computer. I used to be able to access them through win95 and in a pentium
>100 computer; but now I have to work with win98 and a p2. Assembly code used
>to work in the past, but not anymore.

Allan Carlton

Author of Delphi Central at http://www.innotts.co.uk/~zephyr
Providing Delphi Articles, Tutorials and Hints.

Other Threads