Switch LPT1 Pin1 on & off

Hi !
I've searched EE and the Web for switching on/off a PIN of LPT1 under W2K. I always found WinIO
and the WinIO unit. Can somebody explain me how to use this thing ? I only want to turn off/on
one pin. This can't be so hard ?? A short function would be nice.

Thanks
Philip
fuluppiAsked:
Who is Participating?
 
Amir AzhdariConnect With a Mentor Commented:
Hi  Fuluppi,
download this project , it work on my pc :
http://azhdari.europe.webmatrixhosting.net/Q_21095463.zip

Let me know if you have problem yet...
0
 
Amir AzhdariCommented:
Hi,
you can try with zlportio :
http://www.delphi32.org/vcl/4848/

also :
http://sourceforge.net/projects/tpapro
This is the definite component suite for COM port programming.
Manual and sample programs included.

Regards
Amir
0
 
Amir AzhdariCommented:
LPT port address = 378H  OR 278H
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
fuluppiAuthor Commented:
hi amir !
i already tried zlportio. i have no idea how to use it with the parallell
port. can you post some demo code for winio or zlportio ?

Thanks
Philip
0
 
fuluppiAuthor Commented:
i guess it works like this:

  SetPortVal(378,0,0);

what must i set to disable and to enable all pins ?
  SetPortVal(378,256,0); for all on and   SetPortVal(378,0,0); for all off ??
0
 
Amir AzhdariCommented:
the zlportio is include a demo to read/wrtite from/to ports,
anyway, this is some codes :

/////////////////////////////////////////////////////////
// for write to port 378H
procedure TMain.Button1Click(Sender: TObject);
var Port,data:dword;
begin
      try
       Port := str2int('378',true); // str2int func. convert a hex value to decimal.
      except
       Port := 0;
      end;
// it'll write 'FF' (HEX) to the 378H ( enable all the data pins ( pins 2-9) )
 zlioportwrite(port,coDataType.itemindex,str2int('FF', true));

// it'll write '01' (HEX) to the 378H ( enable pin 2 and disable pins 3 - 9 )
//  zlioportwrite(port,coDataType.itemindex,str2int('01', true));

end;
/////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////
// for read from port 378H
procedure TMain.Button2Click(Sender: TObject);
var Port,data:dword;
begin
     try
       Port := str2int('378',true); // str2int func. convert a hex value to decimal.
      except
       Port := 0;
      end;

 setthreadpriority(GetCurrentThread,THREAD_PRIORITY_TIME_CRITICAL);
 data := zlioportread(Port,coDataType.itemindex);
 setrdata(data);
end;
/////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////
function TMain.str2int(const value:string;const HEX:boolean):integer;
begin // convert a hex value to decimal value
  if HEX then
     result := strtoint('$' + value)
    else
     result := strtoint(value);
end;
/////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////
procedure TMain.setrdata(const Data:dword);
begin // convert an integer value to hex value and show that in an edit box
 erData.Text := inttohex(Data,coDataType.Tag);
end;
/////////////////////////////////////////////////////////
0
 
Amir AzhdariCommented:
Also, not bad to take a look at this link for more details about interfacing the standard parallel port :
http://azhdari.europe.webmatrixhosting.net/parallel.pdf

0
 
fuluppiAuthor Commented:
hi amir !
nothing changes on the port when i call the functions with zlio ???
0
 
fuluppiAuthor Commented:
it works ! thanks a lot ! i found a component which works well, too. but it's not free.
0
 
fuluppiAuthor Commented:
In my application it doesn't work any longer.  if ZLIOStarted returns false. Any ideas what I do wrong ? Do I need to do something special to start the driver ???

thanks
philip
0
 
Amir AzhdariCommented:
philip, thanks for the points,

Copy file zlportio.sys to your project directory
It should be in the one directory with you application.
0
 
fuluppiAuthor Commented:
i did that already. still doesn't work.
0
 
fuluppiAuthor Commented:
i found out the problem. my projects ly on a network drive. it only works on a physical disk. no idea why. this is really strange.
0
 
Amir AzhdariCommented:
Hi philip,
I tested that on my client,
you are right, it only works on a physical disk ,not on a network drive,
it's because of the driverinstall func. can't read the driver file from network drive,
so I made some changes to the zlportio.pas file to copy the zlportio.sys to 'C:\' first and then load it from 'C:' instead of
network drive and it work now ,

download the zlportio.pas from here and recompile your project :
http://azhdari.europe.webmatrixhosting.net/zlportio.pas

by the way , don't forget to Copy file zlportio.sys to your project directory
0
 
Amir AzhdariCommented:
0
 
Amir AzhdariCommented:
Hi philip,
did you test your project on the server ?
Let me know if you have any problem
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.