nm i found out it... i will share how i implemented the InternetSetOption
API here - you will need a blank module, and a blank form with two
buttons, Commandd1 and Command2. This can be tested by using the
application to set - and checking online/offline status in MS Outlook
Express or MS IE.
'--------------------------------------------------------------------
'Coding is © 2002 Pierre du Toit
'greywacke@t...
'greywacke@w...
'greywacke@f...
'lythera@h...
'add the following to a module
'constants
Public Const INTERNET_OPTION_CONNECTED_STATE = 50
Public Const INTERNET_STATE_CONNECTED = 1
Public Const INTERNET_STATE_DISCONNECTED_BY_USER = &H10
Public Const ISO_FORCE_DISCONNECTED = 1
'types
Public Type INTERNET_CONNECTED_INFO
dwConnectedState As Long
dwFlags As Long
End Type
'declares
Public Declare Function InternetSetOption Lib "wininet.dll" _
Alias "InternetSetOptionA" ( _
ByVal hInternet As Long, _
ByVal dwOption As Long, _
lpBuffer As Any, _
ByVal dwBufferLength As Long) As Long
'--------------------------------------------------------------------
'add the following to the body of a module
Public Sub SetOfflineStatus(booloffline As Boolean)
Dim ConInfo As INTERNET_CONNECTED_INFO, lRetValue As Long
If booloffline Then
ConInfo.dwConnectedState = INTERNET_STATE_CONNECTED
lRetValue = InternetSetOption(0&, _
INTERNET_OPTION_CONNECTED_STATE, _
ConInfo, Len(ConInfo))
Me.Caption = "Set Offline Status [Working Online]"
Else
ConInfo.dwConnectedState = INTERNET_STATE_DISCONNECTED_BY_USER
ConInfo.dwFlags = ISO_FORCE_DISCONNECTED
lRetValue = InternetSetOption(0&, _
INTERNET_OPTION_CONNECTED_STATE, _
ConInfo, Len(ConInfo))
Me.Caption = "Set Offline Status [Working Offline]"
End If
End Sub
'add the following to the form with two buttons
Private Sub Form_Load()
Command1.Caption = "Work OnLine"
Command2.Caption = "Work OffLine"
Me.Caption = "Set Offline Status"
End Sub
Private Sub Command1.Click()
SetOfflineStatus False
End Sub
Private Sub Command2.Click()
SetOfflineStatus True
End Sub
'--------------------------------------------------------------------