How detect modem status 
Author Message
 How detect modem status

How can I detect the modem status when the modem is
used by another application.
--
DELEAU Jean-Marie



Wed, 08 Mar 2000 03:00:00 GMT  
 How detect modem status

I have found the solution.
The function IsConnected return True if the connection to internet is
successful.
This works only in Win95, not in NT

------------------------------------------------------ BEGIN CODE
--------------------------------------
Attribute VB_Name = "Modem"
Option Explicit
'
'
'*** (c)1997 DELEAU Jean-Marie
'
Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias
"RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As
Long) As Long
Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias
"RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long
'
Public Const RAS95_MaxEntryName = 256
Public Const RAS95_MaxDeviceType = 16
Public Const RAS95_MaxDeviceName = 32
'
Public Type RASCONN95
    dwSize As Long
    hRasCon As Long
    szEntryName(RAS95_MaxEntryName) As Byte
    szDeviceType(RAS95_MaxDeviceType) As Byte
    szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
'
Public Type RASCONNSTATUS95
    dwSize As Long
    RasConnState As Long
    dwError As Long
    szDeviceType(RAS95_MaxDeviceType) As Byte
    szDeviceName(RAS95_MaxDeviceName) As Byte
End Type

Public Function IsConnected() As Boolean
Dim TRasCon(255) As RASCONN95
Dim lg As Long
Dim lpcon As Long
Dim RetVal As Long
Dim Tstatus As RASCONNSTATUS95
'
TRasCon(0).dwSize = 412
lg = 256 * TRasCon(0).dwSize
'
RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
If RetVal <> 0 Then
                    MsgBox "ERROR"
                    Exit Function
                    End If
'*** if RetVal <> 0 then Error
'*** if TRasCon(0).hRascon <>0 then the port is OPEN
'
Tstatus.dwSize = 160
RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
If Tstatus.RasConnState = &H2000 Then
                         IsConnected = True
                         Else
                         IsConnected = False
                         End If

End Function



Thu, 09 Mar 2000 03:00:00 GMT  
 How detect modem status

I know diddly about RAS connections, but I offer a suggestion ....

Since  your IsConnected() routine is defined as Boolean, why not just
evaluate the required result directly as a Boolean, foregoing the need for
an If.. Then.. Else statement?

     IsConnected = Tstatus.RasConnState = &H2000

If Tstatus.RasConnState does equal &H2000, then IsConnected is True.  If
not, it's false.

--
Randy Birch, MVP Visual Basic

Moderator, Fidonet Visual Basic Programmer's Conference
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/



:
:
: I have found the solution.
: The function IsConnected return True if the connection to internet is
: successful.
: This works only in Win95, not in NT
:
:
: ------------------------------------------------------ BEGIN CODE
: --------------------------------------
: Attribute VB_Name = "Modem"
: Option Explicit
: '
: '
: '*** (c)1997 DELEAU Jean-Marie
: '
: Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias
: "RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As
: Long) As Long
: Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias
: "RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long
: '
: Public Const RAS95_MaxEntryName = 256
: Public Const RAS95_MaxDeviceType = 16
: Public Const RAS95_MaxDeviceName = 32
: '
: Public Type RASCONN95
:     dwSize As Long
:     hRasCon As Long
:     szEntryName(RAS95_MaxEntryName) As Byte
:     szDeviceType(RAS95_MaxDeviceType) As Byte
:     szDeviceName(RAS95_MaxDeviceName) As Byte
: End Type
: '
: Public Type RASCONNSTATUS95
:     dwSize As Long
:     RasConnState As Long
:     dwError As Long
:     szDeviceType(RAS95_MaxDeviceType) As Byte
:     szDeviceName(RAS95_MaxDeviceName) As Byte
: End Type
:        
:
:
: Public Function IsConnected() As Boolean
: Dim TRasCon(255) As RASCONN95
: Dim lg As Long
: Dim lpcon As Long
: Dim RetVal As Long
: Dim Tstatus As RASCONNSTATUS95
: '
: TRasCon(0).dwSize = 412
: lg = 256 * TRasCon(0).dwSize
: '
: RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
: If RetVal <> 0 Then
:                     MsgBox "ERROR"
:                     Exit Function
:                     End If
: '*** if RetVal <> 0 then Error
: '*** if TRasCon(0).hRascon <>0 then the port is OPEN
: '
: Tstatus.dwSize = 160
: RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
: If Tstatus.RasConnState = &H2000 Then
:                          IsConnected = True
:                          Else
:                          IsConnected = False
:                          End If
:
: End Function
:  
:



Thu, 09 Mar 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Detecting Modem Status in VB

2. Detect modem status in Win 95 with VB 4?

3. Checking Carrier Detect Status on Modem

4. How to detect the modem OnHook status?

5. Detect Modem (Phone) is Ringing, Answer it and detect Touch Tones

6. hello, how modem status

7. Reading modem status from VB

8. Modem Status Detection - HOW?

9. Modem Status

10. Checking Modem Status

11. monitor the modem status!

12. Q: testing the modem status

 

 
Powered by phpBB® Forum Software