Prevent accessing LPT port by another application

My x64 port of InpOut32
Post Reply
Bednarus3
New User
Posts: 4
Joined: Sat Dec 08, 2018 2:33 pm

Prevent accessing LPT port by another application

Post by Bednarus3 »

I have written C# app that program some eeprom. How can I prevent LPT port from accessing by another process while my app is running? I mean something like c# SerialPort.Open(). After that any other process can't access COM port until SerialPort.Close() instruction.
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: Prevent accessing LPT port by another application

Post by phil »

Sorry I don't know the answer to that! Not sure its possible - certainly not with InpOut32 as that is just a driver to hit any port - there is no exclusivity check (and for there to be, every other app would have to use the same driver - which clearly wont be happening if Windows has other LPT drivers).
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Bednarus3
New User
Posts: 4
Joined: Sat Dec 08, 2018 2:33 pm

Re: Prevent accessing LPT port by another application

Post by Bednarus3 »

It is quite danger to eeprom when I connect programmer with it to LPT port and for example accidentally print some document to LPT printer. I need to make my program safe from any situation like this. I know nobody use LPT printer any more but this is only example.
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: Prevent accessing LPT port by another application

Post by phil »

Yes, I understand the problem, but I cant help I'm afraid.
Inpout32 is a generic port level driver (that I did not even write, I only ported it to x64).
The driver can not be changed as I don't have (and can't get) the ability to sign kernel level drivers anymore (previously a friendly user who had a driver signing cert did this for us).

And even if the driver could be changed, there is nothing you can do in the driver (as far as I know) to lock the port so that other LPT drivers in windows know that it is in use and can't use it (I could be wrong on that but I don't know enough about parallel port hardware to give any concrete answers as to whether you can write something that tells other devices that it is in use).

As you say, no one uses LPT these days. I would have thought that a USB based EEPROM programmer (or even a USB based IO device that you conect to your EEPROM programmer) would be more suitable and less problematic as you and only you would have control over that device (assuming the USB device allows exclusive locks).

Regards,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Bednarus3
New User
Posts: 4
Joined: Sat Dec 08, 2018 2:33 pm

Re: Prevent accessing LPT port by another application

Post by Bednarus3 »

It is quite old eeprom and there is no reasonable price programmers to buy.
User avatar
phil
Site Admin
Posts: 7611
Joined: Sun Apr 06, 2003 11:12 pm

Re: Prevent accessing LPT port by another application

Post by phil »

I understand. At the end of the day you need to decide what your going to do. I cant do that for you. I can only make recommendations based on my experience and what I have done instead of relying on a parallel port as i simply don't know if you can achieve your goal using InpOut32 and direct access to port registers.

This probably wont help but in my experience these are your options...

You could use Linux where there are no such driver restrictions and everything would be under your control - technically this would be free but you would have to do more software work...

Or you could use a "low cost" (not sure what your definition of that would be) USB IO device that provides 8 input/output pins that you can control exclusively (I have done this, not for parallel/eeprom IO but to control inputs and relay connected outputs, that in the past I may have done using the parallel port) I used a one of these velleman devices https://www.velleman.eu/products/view/? ... us&lang=en but I bet you can get cheaper USB io boards these days on ebay... Yep... https://www.amazon.co.uk/ameriDroid-USB ... B01LZT1IMY. This will pretty much future proof it too as USB is here to stay for a while I reckon! NOTE: You wont use InpOut32 with these devices, they come with dev kits and you can talk to them directly (certainly for the velleman - which has a .NET SDK or via a virtual COM port (which you can lock easily as you already know).

Or you could use a separate low cost device like a raspberry pi or arduino which has IO pins you can connect to your eeprom programmer (I have done this but not for eeproms, but for controlling devices with relays) They are great fun to play around with and not exactly expensive. Plus you can use them for all sorts of other funky things (I use my rpi to reset my server remotely, as an apply homekit bridge to control my lights/tv) the possibilities are endless all for not a lot more that $30.

You could hope that nothing in Windows writes to the LPT port and live with the fact that it could go wrong

You could dig out the specs for the LPT port and see if there is anything you can write to any of the port registers that make it locked/exclusive to you. Then you may be able to do this directly using InpOut32...


Good luck,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Bednarus3
New User
Posts: 4
Joined: Sat Dec 08, 2018 2:33 pm

Re: Prevent accessing LPT port by another application

Post by Bednarus3 »

Thank You for Your time. I leave my solution like it is. The risk that another process use LPT port while my app is running is pretty small these days. I have asked because I wonted to improve my software. Eeprom programmer that I have built is for people who can barely use soldering iron. It must be as simple as possible because it is DIY thing.
Post Reply