locked
How to get available Parallel Port(Printer Port) names? RRS feed

  • Question

  • I want to get available parallel port names, like LPT1, LPT2..

    I don't need to interface with printer but need only parallel port names.

    How can I get it?

    Wednesday, November 28, 2018 2:09 AM

Answers

  • Add a reference to System.Management and try this fragment in a Console application:

    using( var searcher = new ManagementObjectSearcher( "Select * From Win32_ParallelPort" ) )

    {

        using( ManagementObjectCollection ports = searcher.Get() )

        {

            foreach( var port in ports )

            {

                Console.WriteLine( port["Name"] );

            }

        }

    }


    Wednesday, November 28, 2018 8:46 AM