 |
aekpong Level: Whizz Kid
 Registered: 27-12-2005 Posts: 14
|
How to run app. When internet connected
How to run application. When internet connected
'=============================
I have application in (c:\myapp.exe) When I connect to internet (status=Connected) I want to run myapp.exe automatic
'=================================
Please help me with "dial up script" or by anyway to success to run myapp.exe
Best regard.
TK.
____________________________
TK
|
|
17-03-2006 at 11:15 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: How to run app. When internet connected
You would need to have one app that will be running in the background (no visible interface, should be started when OS id loaded), which will check for internet connection from time to time). When it detects that connection is established, it should run your 2nd app.
To check if there is an internet connection (code by Francesco Balena):
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef _
lpSFlags As Long, ByVal dwReserved As Long) As Long
Const INTERNET_CONNECTION_MODEM = 1
Const INTERNET_CONNECTION_LAN = 2
Const INTERNET_CONNECTION_PROXY = 4
Const INTERNET_CONNECTION_MODEM_BUSY = 8
' return True if there is an active Internect connection
'
' optionally returns the connection mode through
' its argument (see INTERNET_CONNECTION_* constants)
' 1=modem, 2=Lan, 4=proxy
' 8=modem busy with a non-internet connection
Function IsConnectedToInternet(Optional connectMode As Integer) As Boolean
Dim flags As Long
' this ASPI function does it all
IsConnectedToInternet = InternetGetConnectedState(flags, 0)
' return the flag through the optional argument
connectMode = flags
End Function |
[Edited by Goran on 17-03-2006 at 09:41 PM GMT]
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
17-03-2006 at 08:32 PM |
|
|
aekpong Level: Whizz Kid
 Registered: 27-12-2005 Posts: 14
|
Re: How to run app. When internet connected
Private Sub Timer1_Timer()
If IsConnectedToInternet(INTERNET_CONNECTION_MODEM) = True Then
List1.AddItem "Internet connection State (modem) = Connected" & vbCrLf
Else
List1.AddItem "Internet connection State (modem) = Not Connected" & vbCrLf
End If
End Sub
'Now IsConnectedToInternet(INTERNET_CONNECTION_MODEM) function return >> true. if local area connection connected.
'How to get Internet connection of modem(ppp adapter) connected only. But Local area connection and (ppp adapter(modem)) can Active at the same time
I hope for help again.
TK.
____________________________
TK
|
|
18-03-2006 at 03:26 AM |
|
|
Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: How to run app. When internet connected
If you look athis function and how it woks, you will that the parrameter you pass to IsConnectedToInternet is NOT used in InternetGetConnectedState API. When InternetGetConnectedState API executes it retunrs the value in flags parameter, and in nect line it sets flags value to a parameter you have passed to the function .This is the value you need to examine, not the returned value of function.
dim RetVal As Integer
IsConnectedToInternet RetVal
If (RetVal And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then Debug.Print "Modem connection."
If (RetVal And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then Debug.Print "connected through LAN." |
etc, etc
____________________________
If you find the answer helpful, please mark this topic as solved.
|
|
18-03-2006 at 10:29 AM |
|
|
|
|
 |
 |