C# 如何找到打印机';s流控制,无论是硬件还是软件

C# 如何找到打印机';s流控制,无论是硬件还是软件,c#,wpf,C#,Wpf,但我不知道这种方法是否正确,以获得这样的输出(上图)。我只是搞砸了 如果你知道正确的方法,请告诉我,我只是升级它 最后,我需要找到流量控制(软件或硬件)。如上图所示,组合框必须指向属于软件设备的设备。因此,我必须动态查找该值(s/w或h/w) using System; using System.Collections.Generic; using System.Text; using System.Windows; using System.Windows.Controls; using Sy

但我不知道这种方法是否正确,以获得这样的输出(上图)。我只是搞砸了 如果你知道正确的方法,请告诉我,我只是升级它

最后,我需要找到流量控制(软件或硬件)。如上图所示,组合框必须指向属于软件设备的设备。因此,我必须动态查找该值(s/w或h/w)

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Printing;
using System.IO.Ports;

namespace Printer
{   
    public partial class portname : Window
    {  



    PrintServer server = new PrintServer();  
    public portname()
    {
        this.InitializeComponent();


        foreach (PrintQueue queue in server.GetPrintQueues())
        {

            com_pinter.Items.Add(queue.FullName);

        }

        var DefaultPrinter = new LocalPrintServer().DefaultPrintQueue;      

        string default_name=DefaultPrinter.FullName;

        txt_dpn.Text = "Default printe is " + " " + default_name.ToUpper();

        string default_port = DefaultPrinter.QueuePort.Name; 

        txt_pn.Text = "PortName is" + " " + default_port.ToUpper();
    }

    private void com_pinter_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        foreach (PrintQueue queue in server.GetPrintQueues())
        {
            string selecteditem = com_pinter.SelectedItem.ToString();
            string portname = queue.FullName;

            SerialPort mySerialPort = new SerialPort(queue.QueuePort.Name);
            btn_br.Content = mySerialPort.BaudRate;
            btn_db.Content = mySerialPort.DataBits;
            btn_pty.Content = mySerialPort.Parity;
            btn_sb.Content = mySerialPort.StopBits;

            if (selecteditem == portname)
            {
                string select_portname = queue.QueuePort.Name;
                txt_pn.Text = "PortName is" + " " + select_portname.ToUpper();
            }
        }
    }


}


}