-1
我已将客户显示器与POS应用程序连接起来。我正在使用串行端口类在客户显示器上显示消息。要发送消息,我需要使用com端口了解此USB显示器正在使用。我搜索允许有很多例子,让所有的comump壶,但我能够找到任何帮助,以获得微小的COM端口号,例如COM93,COM01或COM2。确定(启用USB)消费者显示器的COM端口
我试过下面的程序,我也试过微软程序的WMI代码的创建者。
//获取串口名称列表。 string [] ports = SerialPort.GetPortNames();
Console.WriteLine("The following serial ports were found:");
// Display each port name to the console.
foreach (string port in ports)
{
Console.WriteLine(port);
}
Console.ReadLine();
SerialPort sp = new SerialPort();
sp.PortName = "COM93";------------- How i can find this no automatic
sp.BaudRate = 9600;
sp.Parity = Parity.None;
sp.DataBits = 8;
sp.StopBits = StopBits.One;
sp.Open();
sp.Write("\f");
sp.WriteLine("***Velkommen***");
sp.Close();
sp.Dispose();
sp = null;
我曾尝试以下解决方案为好,用这个也为了这个,我得到Access denied,所以我需要编辑registory给我点瓦纳做我想做的解决方案编程
ManagementObjectSearcher搜索权= new ManagementObjectSearcher(“root \ WMI”,“SELECT * FROM MSSerial_PortName”);