void GetPort()
{
Microsoft.Win32.RegistryKey hklm= Microsoft.Win32.Registry.LocalMachine;
Microsoft.Win32.RegistryKey software11= hklm.OpenSubKey("HARDWARE");
//打开"HARDWARE"子健
Microsoft.Win32.RegistryKey software= software11.OpenSubKey("DEVICEMAP");
Microsoft.Win32.RegistryKey sitekey= software.OpenSubKey("SERIALCOMM");
//获取当前子健
String []Str2= sitekey.GetValueNames;
//Str2=System.IO.Ports.SerialPort.GetPortNames();//第二中方法,直接取得串口值
//获得当前子健下面所有健组成的字符串数组
Integer ValueCount= sitekey.ValueCount;
//获得当前子健存在的健值
int i;
for( i=0;i< ValueCount;i++)
{
comboBox1.Items.Add(sitekey.GetValue(Str2[i]));
}
}
combobox1显示当前端口号