Link to home
Start Free TrialLog in
Avatar of Amir Azhdari
Amir AzhdariFlag for United States of America

asked on

writing to parallel port in windows NT

hi ,
how i can write a byte of data to parallel port in windows NT ( without using components ) ?


Thanks you very much.

regards,
Amir
Avatar of emadat
emadat
Flag of United States of America image

Hi Amir,

Here is an article called "Using the Parallel Port as an Input/Output Channel":
http://digital.ni.com/public.nsf/websearch/953a4ab52663089d85256427004778c4?OpenDocument

And here are some procedures to write, reset and read parallel port:
//********************************************************
procedure WriteToPort(PortAddress, DataValue: Word);
begin
    DataValue := (DataValue*256) + DataValue;
    asm
        Mov ax, DataValue
        Mov dx, PortAddress
        Out dx, ax
    end;
end;
//********************************************************
procedure ResetPort(PortValue: word);
begin
    asm
        Mov ax,0
        Mov dx,PortValue
        Out dx,ax
    end;
end;
//********************************************************
function TBAIOPort.ReadPort(PortValue: word): word;
var
    ReadData: word;
begin
    asm
        Mov dx, PortValue
        In ax, dx
        Mov ReadData, ax
    end;
    Result := Byte(ReadData);
end;
//********************************************************

Good luck,
Emad
ASKER CERTIFIED SOLUTION
Avatar of Gwena
Gwena

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Amir Azhdari

ASKER

Dear Gwena
can you send me your source code Please ?
my email : azhdari@lycos.com

Thank you Gwena... you really helped me.
Gwena have you deleted the file from server? Can't download it :(
Hi ginsonic
you have to right click the link to the file and select
'save target as' to download it..
Avatar of Gwena
Gwena

Hi AmirAzhdari :-)

I will send the code to your email
It was compiled using D2 standard
and there is a component you would need
to handle the fancy form shape...

But the main unit code will show you exactly
how to make easy use of zlportio

oh... also a small util I wrote would be needed to
stuff the zlportio.sys into the compiled exe so that
it can be extracted at runtime with my exemod.pas unit

exemod.pas is in the source code...

any questions about the source just ask... I did not
comment it :-)