Solved

Switch LPT1 Pin1 on & off

Posted on 2004-08-16
16
760 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:fuluppi
  • 9
  • 7
16 Comments
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11817865
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
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11817874
LPT port address = 378H  OR 278H
0
 

Author Comment

by:fuluppi
ID: 11818009
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
 

Author Comment

by:fuluppi
ID: 11818150
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
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11818869
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
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11818898
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
 

Author Comment

by:fuluppi
ID: 11820076
hi amir !
nothing changes on the port when i call the functions with zlio ???
0
 
LVL 6

Accepted Solution

by:
Amir Azhdari earned 500 total points
ID: 11820739
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:fuluppi
ID: 11820891
it works ! thanks a lot ! i found a component which works well, too. but it's not free.
0
 

Author Comment

by:fuluppi
ID: 11821143
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
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11822036
philip, thanks for the points,

Copy file zlportio.sys to your project directory
It should be in the one directory with you application.
0
 

Author Comment

by:fuluppi
ID: 11822284
i did that already. still doesn't work.
0
 

Author Comment

by:fuluppi
ID: 11823710
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
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11825208
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
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11825319
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 11838261
Hi philip,
did you test your project on the server ?
Let me know if you have any problem
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now