|
|
Title | See if the system is connected to the network using API functions |
Description | This example shows how to See if the system is connected to the network using API functions in Visual Basic 6. The program uses the InternetGetConnectedStateEx function to get information about the connection. |
Keywords | RAS, network, connected, connection |
Categories | Software Engineering |
|
|
Use the InternetGetConnectedStateEx function. This function returns the connection name and other information about the network configuration.
|
|
Private Sub Form_Load()
Dim flags As Long
Dim length As Long
Dim connection_name As String
Dim connected As Boolean
Dim ctl As Control
length = 256
connection_name = Space$(length)
connected = InternetGetConnectedStateEx(flags, _
connection_name, length, 0&)
For Each ctl In Controls
If TypeOf ctl Is CheckBox Then ctl.Value = _
vbUnchecked
Next ctl
If connected Then
lblConnection.Caption = Left$(connection_name, _
InStr(connection_name, Chr$(0)) - 1)
If flags And INTERNET_CONNECTION_CONFIGURED Then _
chkConfigured.Value = vbChecked
If flags And INTERNET_CONNECTION_LAN Then _
chkLan.Value = vbChecked
If flags And INTERNET_CONNECTION_MODEM Then _
chkModem.Value = vbChecked
If flags And INTERNET_CONNECTION_OFFLINE Then _
chkOffline.Value = vbChecked
If flags And INTERNET_CONNECTION_PROXY Then _
chkProxy.Value = vbChecked
If flags And INTERNET_RAS_INSTALLED Then _
chkRASInstalled.Value = vbChecked
End If
End Sub
|
|
|
|
|
|