Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find Modem Name and commport
Message
From
27/02/2004 10:14:20
 
 
To
27/02/2004 00:29:41
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00881363
Message ID:
00881469
Views:
19
>Dear Sir,
>
>Is there anyway to detect modem name and commport,
>onwhich the modem is attached, on my computer.
>
>Please help

In addition to Viv's advice, another method based on Ed Rauh's FAQ#7943:
LOCAL ocomm, x, colderrorhandler, lncomports, lcbuffer
DECLARE acomports[16]
FOR x = 1 TO 16
  acomports[x] = x
ENDFOR
colderrorhandler = ON('ERROR')
FOR x = 1 TO 16
  ocomm = CREATEOBJ('MsCOMMLib.Mscomm')
  ocomm.commport = x
  ON ERROR acomports[x] = .F.
  ocomm.portopen = .T.
  ocomm.portopen = .F.
  ocomm = NULL
  ON ERROR &colderrorhandler
ENDFOR

lncomports = 0
FOR x = 1 TO 16
  IF VARTYPE(acomports[x]) = 'L'
    ADEL(acomports,x)
  ELSE
    lncomports = lncomports + 1 
  ENDIF
ENDFOR
DIMENSION acomports[lncomports]

lcbuffer = ""
ocomm = CREATEOBJ('MsCOMMLib.Mscomm')
FOR x = 1 TO ALEN(acomports)
  ocomm.commport = acomports[x]
  ocomm.rtsenable = .T.
  ocomm.dtrenable = .T.
  ocomm.portopen = .T.
  ocomm.output = "ATI3"+CHR(13)
  WAIT "Waiting for port..." WINDOW TIMEOUT 2
  lcbuffer = ocomm.input
  IF !EMPTY(lcbuffer)
    ? "Modem on COM" + ALLTRIM(STR(acomports[x])) + ": " + lcbuffer
    lcbuffer = ""
  ENDIF 
  ocomm.rtsenable = .F.
  ocomm.dtrenable = .F.
  ocomm.portopen = .F.
ENDFOR
ocomm = NULL
Previous
Reply
Map
View

Click here to load this message in the networking platform