How to open the site automatically when an internet connection is available

We will create a program that is able to open a website when the internet connection is available. Method of running a website automatically has long been used, where the objective is to increase page rank of a website. However, in order to trick the user or owner of the PC, the program deliberately created to work behind the screen (invisible).

But this time I just gave an example of simple source code only, I would not teach a trick or ruse compete unfairly to you.

To make this simple program, required a command button and a timer. For timer1, set the interval = 1000 and set enable = false



Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long

Private Sub Command1_Click()
If Command1.Caption = "Run" Then
Timer1.Enabled = True
Command1.Caption = "Stop"
Else
Timer1.Enabled = False
Command1.Caption = "Run"
End If
End Sub

Private Sub Form_Load()

End Sub

Private Sub Timer1_Timer()
If Second(Now) Mod 30 = 0 Then
If InternetCheckConnection("http://ambarhalim.blogspot.com", FLAG_ICC_FORCE_CONNECTION, 0&) = 1 Then
Shell "explorer.exe http://ambarhalim.blogspot.com"
End If
End If
End Sub


Copy the code above!

InternetCheckConnection function will give the value of presence or absence of an internet connection. This procedure will work once every 30 seconds.


Keyword: Force Connection | Auto Open a Website | Source Code Auto Open a Website

You may also like: