-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlockWeb.vb
41 lines (35 loc) · 1.54 KB
/
BlockWeb.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Imports System.IO
Public Class BlockWeb
Private Sub logout_Click(sender As Object, e As EventArgs) Handles logout.Click
Hide()
Login.Show()
End Sub
Private Sub exitbutton_Click(sender As Object, e As EventArgs) Handles exitbutton.Click
Application.Exit()
End Sub
Private Sub block_Click(sender As Object, e As EventArgs) Handles block.Click
Dim m As String = urlbox.Text
Dim FILE_NAME As String = "C:\Windows\system32\drivers\etc\hosts"
Dim aryText As String
aryText = "127.0.0.1" & Space(4) & m
Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
objWriter.WriteLine(aryText)
objWriter.Close()
MsgBox(m & " Has been Blocked")
End Sub
Private Sub viewurl_Click(sender As Object, e As EventArgs) Handles viewurl.Click
Dim s As String = My.Computer.FileSystem.ReadAllText("C:\Windows\system32\drivers\etc\hosts")
MsgBox(s)
End Sub
Private Sub unblock_Click(sender As Object, e As EventArgs) Handles unblock.Click
Dim m As String = urlbox.Text
Dim FILE_NAME As String = "C:\Windows\system32\drivers\etc\hosts"
Dim fileReader As String = My.Computer.FileSystem.ReadAllText(FILE_NAME).Replace("127.0.0.1" & Space(4) & m, "")
My.Computer.FileSystem.WriteAllText(FILE_NAME, fileReader, False)
MsgBox(m & " Has been UnBlocked")
End Sub
Private Sub menubutton_Click(sender As Object, e As EventArgs) Handles menubutton.Click
Hide()
MyMenu.Show()
End Sub
End Class