求教:VB能不能做这样一个软件
											VB能不能做这样一个软件:检测COM端口和网络是否有信号连接,如果这两者没有信号从电脑输出一个信号(USB)触发蜂鸣器。
理论上C++可以实现吗?
谢谢!
程序代码:Option Explicit
Private Type DCB
        DCBlength As Long
        BaudRate As Long
        fBitFields As Long
        wReserved As Integer
        XonLim As Integer
        XoffLim As Integer
        ByteSize As Byte
        Parity As Byte
        StopBits As Byte
        XonChar As Byte
        XoffChar As Byte
        ErrorChar As Byte
        EofChar As Byte
        EvtChar As Byte
        wReserved1 As Integer
End Type
Private Type COMMCONFIG
    dwSize As Long
    wVersion As Integer
    wReserved As Integer
    dcbx As DCB
    dwProviderSubType As Long
    dwProviderOffset As Long
    dwProviderSize As Long
    wcProviderData As Byte
End Type
Private Declare Function GetDefaultCommConfig Lib "kernel32" _
  Alias "GetDefaultCommConfigA" (ByVal lpszName _
  As String, lpCC As COMMCONFIG, _
   lpdwSize As Long) As Long
程序代码:
Public Function ComPortExists(ByVal ComPort As Integer) _
   As Boolean
'*****************************************************
'EXAMPLE
    'Dim bAns As Boolean
    'bAns = ComPortExists(1)
    'If bans then
        'msgbox "Com Port 1 is available
    'Else
        'msgbox "Com Port 1 is not available
    'End if
'*************************************************
    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