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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining LPT address

Status
Not open for further replies.

alvinleer

Technical User
Aug 5, 2004
2
ZA
Hello,

I am trying to determine the address of the parallel ports on a PC. The base address is $408, this should hold 888 (lpt1 $378).
I have this code segement but I get an access violation. I am not sure if Windows XP is preventing me from reading the data from this memory location.

If anyone could shed some light on this problem or even offer an alternative solution I would be most grateful.

As an aside, I have a PCI parallel port also. How do I write/read to this port? Where can I find the address of this port.

Thanks
Alvin

Code:
procedure find_port ;
var
  ptraddr : ^cardinal;  //* Pointer to location of Port Addresses */
  LPTAddress : array[1..3] of cardinal;       //* Address of Port */
  count : integer;
begin

  ptraddr:=ptr($00000408);

  for count := 1 to 3 do
    begin
      LPTAddress[count] := (ptraddr^);
      if ( LPTAddress[count] = 0 )    then
        showmessage('No port found for LPT'+inttostr(count))
      else
         showmessage('LPT'+inttostr(count)+' is '+inttostr(LPTAddress[count]));
         inc(ptraddr);
    end;
end;
 
you can't have direct access to hardware on windows NT/2000/XP, direct I/O access is reserved for kernel drivers.

so 2 solutions here :
a) write a kernel driver
-> not easy and must be done in visual studio in C with device drivers SDK.
b) use a third party driver.

I personally use the gwiopm.sys driver for driving LCD panels via the printer port. have a look :


don't hesitate to ask more questions...

cheers!

--------------------------------------
What You See Is What You Get
 
Thanks for the reply..

Sorry for the delay.

I abandoned the idea of searching for the available ports. Just allow the user to set an address - this can be dangerous but for now I will leave it in - just for development.

I am using inpout32.dll and it works quite well .

Thanks
Alvin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top