Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Am I connected to Internet? 1

Status
Not open for further replies.

gvt

Programmer
Jul 19, 2000
14
SE
Thinking of an application which whenever I run it on a computer should state if that computer is connected to Internet or not. I am not interested in finding out the type of connection (modem, ISDN, T1 and so on) but just if there is a connection or not.<br>Do you know if it is possible to find out this by checking the Registry or some other strange files which could be modified each time the computer connects or disconnects from Internet?<br>If it is not possible to find out that way, could you please point me in the right direction and tell me where to begin and what to look for? Maybe you have seen a similar example somewhere?<br><br>P.S. I believe that this question has been answered many times before but please have patience.<br><br>Thank you for your time, God bless.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Living la vida loca,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vio<br>
 
If the user has a dialup networking connection then you would want to check if a connection has been established. This can be done with the RasEnumConnections function (in the RAS API) or by using a third-party control such as the one we include with SocketWrench. Another option would be to use the WinInet IneternetGetConnectedState function, but this has some limitations (it requires Internet Explorer, and isn't terribly reliable in determining if you're actually connected to the Internet). You could also try throwing some pings (ICMP ECHO<br>datagrams) off the mail server to determine if you can reach it. <br>&nbsp;<br>michael <p>Mikey<br><a href=mailto:michael.mann@super-set.com>michael.mann@super-set.com</a><br><a href= > </a><br>
 
Here's the RAS API Mikal613 referred to:<br>Use these declarations....<br><FONT FACE=monospace><b><br>Public Type RASCONN95<br>&nbsp;&nbsp;&nbsp;&nbsp;dwSize As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;hRasCon As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;szEntryName(RAS95_MaxEntryName) As Byte<br>&nbsp;&nbsp;&nbsp;&nbsp;szDeviceType(RAS95_MaxDeviceType) As Byte<br>&nbsp;&nbsp;&nbsp;&nbsp;szDeviceName(RAS95_MaxDeviceName) As Byte<br>End Type<br><br>Public Type RASCONNSTATUS95<br>&nbsp;&nbsp;&nbsp;&nbsp;dwSize As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;RasConnState As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;dwError As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;szDeviceType(RAS95_MaxDeviceType) As Byte<br>&nbsp;&nbsp;&nbsp;&nbsp;szDeviceName(RAS95_MaxDeviceName) As Byte<br>End Type<br><br>Public Declare Function RasEnumConnections _<br>&nbsp;&nbsp;&nbsp;&nbsp;Lib &quot;RasApi32.dll&quot; Alias &quot;RasEnumConnectionsA&quot; _<br>&nbsp;&nbsp;&nbsp;&nbsp;(lpRasCon As Any, lpcb As Long, _<br>&nbsp;&nbsp;&nbsp;&nbsp;lpcConnections As Long) As Long<br>Public Declare Function RasGetConnectStatus Lib _<br>&nbsp;&nbsp;&nbsp;&nbsp;&quot;RasApi32.dll&quot; Alias &quot;RasGetConnectStatusA&quot; _<br>&nbsp;&nbsp;&nbsp;&nbsp;(ByVal hRasCon As Long, lpStatus As Any) As Long<br></font></b><br>Use this function to determine is there is a connection:<FONT FACE=monospace><b><br>Public Function IsConnected() As Boolean<br>Dim TRasCon(255) As RASCONN95<br>Dim lg As Long<br>Dim lpcon As Long<br>Dim RetVal As Long<br>Dim Tstatus As RASCONNSTATUS95<br>TRasCon(0).dwSize = 412<br>lg = 256 * TRasCon(0).dwSize<br>RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)<br>If RetVal &lt;&gt; 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit Function<br>End If<br>Tstatus.dwSize = 160<br>RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)<br>If Tstatus.RasConnState = &H2000 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;IsConnected = True<br>Else<br>&nbsp;&nbsp;&nbsp;&nbsp;IsConnected = False<br>End If<br>End Function<br></font><b><br> <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top