Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send data to port directly?

Status
Not open for further replies.

premiK

Programmer
Jan 8, 2002
22
CA
Can any one tell me How to send data to port directly?
Thanks
 
On which port u want to send data..
If u r talking about EDI communication then u can use Sockets(TClientSocket).
And you have to specify the Socket type either it is Blocking or nonblocking, I suggest use blocking socket.

After Creating TClientSocket provide IP address of the machine and port number


 
If you are talking about a Hardware Port you might want to use a third party (freeware) component like CPort Lib by Dejan Crnila, we just changed over to this one as it is multithreaded and works with W2000/NT as well as W9X.

Steve.
 
I want to display the data through the port LPT1. I hope this will work for me
assignfile(port,'stringvalue');
Thnk u very much
 
This works for me in Win9x (Not NT 2K)

procedure PortOut(IOport:word; Value:byte);

//Use these values when calling the port function

Data:=888;
Status:=889;
Control:=890;

PortOut(control,1); //sets strobe output hi

PortOut(control,0); //sets strobe output lo

//Function to read the status of the printer port

function PortIn(IOport:word):byte; assembler;
asm
push dx
mov dx,ax
in al,dx
pop dx
end;

//Procedure to send data to the printer port

Procedure TMainForm.PortOut(IOport:word; Value:byte); assembler;
asm
push dx
mov dx,IOport
mov al,Value
out dx,al
pop dx
end;

PS With thanks to whoever posted this on the Internet in the first place (I forgot who)

Best Regards

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top