|
-
Aug 3rd, 2018, 05:06 AM
#1
Thread Starter
Member
How can I display a MessageBox when a website being searched is blocked by host?
I have an application which adds text to the hosts file from a .txt file full of blacklisted websites.
It works, however, when the website is blocked, I want a Message to come up saying "Website Blocked". This is my code:
Code:
Public Function Initizalize() As String
Dim systemroot As String
Dim root As String
systemroot = Environment.GetEnvironmentVariable("SystemRoot")
root = (systemroot + "\system32\drivers\etc\hosts")
Return root
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim dir As String
dir = Me.Initizalize
Dim systemroot As String
Dim root As String
systemroot = Environment.GetEnvironmentVariable("SystemRoot")
root = (systemroot + "\system32\drivers\etc\hosts")
Dim line As String
Dim sr = New StreamReader("whitelistsites.txt")
line = sr.ReadLine
Dim filePath = "C:\Windows\System32\drivers\etc\hosts"
File.WriteAllLines(filePath, File.ReadAllLines(filePath).Where(Function(s) s <> line))
File.AppendAllText(dir, (Environment.NewLine _
+ (line + Environment.NewLine)))
While ((Not (line) Is Nothing) _
AndAlso (line <> ""))
MessageBox.Show(("Appeanding Line: " + line))
File.AppendAllText(dir, (line + Environment.NewLine))
line = sr.ReadLine
End While
sr.Close()
MessageBox.Show("Done!")
End Sub
So, what I'm trying to say, is that when a website is searched [EDITED]FROM[/EDITED] the host file, it goes to the page on Chrome, then, once it goes to that page, I want a MessageBox to appear. Is there a way to do this?
I know, I've mentioned the Initialize code twice, but, I'm just going to leave it. Please comment for any more info. I didn't explain this very well, I know.
Maybe Google provides an API to do this? But what about for ALL browsers?
Last edited by Modulus; Aug 3rd, 2018 at 05:41 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|