Search code examples
c#parallel-port

Detect if parallel port exists


I have a C# program that manipulates 2 wires using a variety of methods one of which is using a parallel port interface.

The user selects which method they would like to use and I would like to filter the options based on what is available on the machine.

I have been using inpout32.dll for the parallel port communications but it gives no error if the computer has no parallel port so I need another way to tell.

I have seen numerous examples that look up the available printers to find the port, but no printer is connected so this solution will not work.


Solution

  • you can enumerate the devices via the WMI interface

    here is an article:

    http://www.codeproject.com/Articles/18268/How-To-Almost-Everything-In-WMI-via-C-Part-3-Hardw

    there also exists a class called "Win32_ParallelPort: The Parallel ports"