public void AllComNameOne()
{
//1,读取本机所有Com端口
RegistryKey keyCom = Registry.LocalMachine.OpenSubKey("HardWare\\DeviceMap\\SerialComm");
if (keyCom != null)
{
string[] sSubKeys = keyCom.GetValueNames();
this.cbPort.Items.Clear();
foreach (string name in sSubKeys)
{
string sValue = (string)keyCom.GetValue(name);
this.cbPort.Items.Add(sValue);
}
}
}
public void AllComNameTwo()
{
//2,读取本机所有Com端口
this.cbSerialPort.Items.Clear();
string[] comNames = SerialPort.GetPortNames();
foreach (string comName in comNames)
{
this.cbSerialPort.Items.Add(comName);
}
}
/// <summary>
/// 禁止窗体拖曳
/// </summary>
/// <param name="m"></param>
protected override void WndProc(ref Message m)
{
if (m.Msg == 0xA1 && m.WParam.ToInt32() == 2)
return;
base.WndProc(ref m);
}