uses Registry;<br><br>procedure TForm1.Button3Click(Sender: TObject);<br>var <br> reg : TRegistry;<br> ts : TStrings;<br> i : integer;<br>begin<br> reg := TRegistry.Create;<br> try<br> reg.RootKey := HKEY_LOCAL_MACHINE;<br> reg.OpenKey('hardware/devicemap/serialcomm',false);<br> ts := TStringList.Create;<br> try<br> reg.GetValueNames(ts); //获得子键下的所有项<br> for i := 0 to ts.Count -1 do<br> begin //把每一项下的串值显示在Memo1中<br> Memo1.Lines.Add(reg.ReadString(ts.Strings));<br> end;<br> finally<br> ts.Free;<br> end;<br> finally<br> reg.CloseKey;<br> reg.free;<br> end;<br>end;<br><br>以上程序可以判断哪些串口已经被使用.