Public Function ComPortExists(ByVal ComPort As Integer) _
   As Boolean
    Dim udtComConfig As COMMCONFIG
    Dim lUDTSize As Long
    Dim lRet As Long
    
    lUDTSize = LenB(udtComConfig)
    lRet = GetDefaultCommConfig("COM" + Trim(Str(ComPort)) + _
        Chr(0), udtComConfig, lUDTSize)
    ComPortExists = lRet <> 0
End Function