01.
Dim
IsBlocked
As
Boolean
02.
IsBlocked = CheckIsBlocked(txtSite.Text)
03.
04.
If
IsBlocked =
False
Then
05.
Dim
path
As
[
String
] =
"C:\Windows\System32\drivers\etc\hosts"
06.
Dim
sw
As
New
StreamWriter(path,
True
)
07.
Dim
sitetoblock
As
[
String
] = vbCrLf &
"127.0.0.1 "
& txtSite.Text
08.
sw.Write(sitetoblock)
09.
sw.Close()
10.
11.
AddNewSiteToDb(txtSite.Text)
12.
13.
ServiceController1.
Stop
()
14.
MessageBox.Show(
"Site "
& txtSite.Text &
" Blocked"
)
15.
ServiceController1.Start()
16.
txtSite.Clear()
17.
Else
18.
MsgBox(
"The site "
& txtSite.Text &
" has already blocked."
)
19.
txtSite.Clear()
20.
End
If
21.
End
Sub